annotate gcc/testsuite/gcc.dg/c11-static-assert-3.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test C11 static assertions. Invalid assertions. */
kono
parents:
diff changeset
2 /* { dg-do compile } */
kono
parents:
diff changeset
3 /* { dg-options "-std=c11 -pedantic-errors" } */
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 _Static_assert (__INT_MAX__ * 2, "overflow"); /* { dg-warning "integer overflow in expression" } */
kono
parents:
diff changeset
6 /* { dg-error "overflow in constant expression" "error" { target *-*-* } .-1 } */
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 _Static_assert ((void *)(__SIZE_TYPE__)16, "non-integer"); /* { dg-error "not an integer" } */
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 _Static_assert (1.0, "non-integer"); /* { dg-error "not an integer" } */
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 _Static_assert ((int)(1.0 + 1.0), "non-constant-expression"); /* { dg-error "not an integer constant expression" } */
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 int i;
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 _Static_assert (i, "non-constant"); /* { dg-error "not constant" } */
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 void
kono
parents:
diff changeset
19 f (void)
kono
parents:
diff changeset
20 {
kono
parents:
diff changeset
21 int j = 0;
kono
parents:
diff changeset
22 for (_Static_assert (sizeof (struct s { int k; }), ""); j < 10; j++) /* { dg-error "loop initial declaration" } */
kono
parents:
diff changeset
23 ;
kono
parents:
diff changeset
24 }
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 _Static_assert (1, 1); /* { dg-error "expected" } */
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 _Static_assert (1, ("")); /* { dg-error "expected" } */