PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / gnu99-const-expr-2.c
blob4ce5445c61d1ea27490b9e9ae558ff1893e82401
1 /* Test for constant expressions: __builtin_choose_expr. */
2 /* Origin: Joseph Myers <joseph@codesourcery.com> */
3 /* { dg-do compile } */
4 /* { dg-options "-std=gnu99 -pedantic-errors" } */
6 #include <limits.h>
8 int a, b, c;
10 void
11 f (void)
13 /* __builtin_choose_expr acts exactly like the chosen argument for
14 all constant expression purposes. */
15 enum e {
16 E1 = __builtin_choose_expr (1, 1, ++b)
18 /* The first argument to __builtin_choose_expr must be an integer
19 constant expression. */
20 a = __builtin_choose_expr ((void *)0, b, c); /* { dg-error "constant" } */
21 a = __builtin_choose_expr (0 * (INT_MAX + 1), b, c); /* { dg-warning "integer overflow in expression" } */
22 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
23 a = __builtin_choose_expr (1 / 0, 0, 0); /* { dg-warning "division by zero" } */
24 /* { dg-error "not a constant" "error" { target *-*-* } .-1 } */
25 a = __builtin_choose_expr ((1 ? 1 : a), b, c); /* { dg-error "constant" } */