annotate gcc/testsuite/gcc.dg/gnu89-const-expr-2.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for constant expressions: __builtin_choose_expr. */
kono
parents:
diff changeset
2 /* Origin: Joseph Myers <joseph@codesourcery.com> */
kono
parents:
diff changeset
3 /* { dg-do compile } */
kono
parents:
diff changeset
4 /* { dg-options "-std=gnu89 -pedantic-errors" } */
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 #include <limits.h>
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 int a, b, c;
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 void
kono
parents:
diff changeset
11 f (void)
kono
parents:
diff changeset
12 {
kono
parents:
diff changeset
13 /* __builtin_choose_expr acts exactly like the chosen argument for
kono
parents:
diff changeset
14 all constant expression purposes. */
kono
parents:
diff changeset
15 enum e {
kono
parents:
diff changeset
16 E1 = __builtin_choose_expr (1, 1, ++b)
kono
parents:
diff changeset
17 };
kono
parents:
diff changeset
18 /* The first argument to __builtin_choose_expr must be an integer
kono
parents:
diff changeset
19 constant expression. */
kono
parents:
diff changeset
20 a = __builtin_choose_expr ((void *)0, b, c); /* { dg-error "constant" } */
kono
parents:
diff changeset
21 a = __builtin_choose_expr (0 * (INT_MAX + 1), b, c); /* { dg-warning "integer overflow in expression" } */
kono
parents:
diff changeset
22 /* { dg-error "overflow in constant expression" "constant" { target *-*-* } .-1 } */
kono
parents:
diff changeset
23 a = __builtin_choose_expr (1 / 0, 0, 0); /* { dg-warning "division by zero" } */
kono
parents:
diff changeset
24 /* { dg-error "not a constant" "error" { target *-*-* } .-1 } */
kono
parents:
diff changeset
25 a = __builtin_choose_expr ((1 ? 1 : a), b, c); /* { dg-error "constant" } */
kono
parents:
diff changeset
26 }