Add new test to verify that the array index, limit, and stride are
[official-gcc.git] / gcc / testsuite / gcc.dg / Wcxx-compat-8.c
blobf7e8c557914625d909e5aa52b4419488be2989d8
1 /* { dg-do compile } */
2 /* { dg-options "-Wc++-compat" } */
4 struct s1
6 enum e1 /* { dg-message "note: enum type defined here" } */
8 A = sizeof (struct s2 { int i; }), /* { dg-warning "invalid in C\[+\]\[+\]" } */
10 } f1;
12 struct s2 v1; /* Don't issue another warning about s2. */
13 enum e1 v2; /* { dg-warning "not visible in C\[+\]\[+\]" } */
15 enum e2
17 C = sizeof (struct s3 { int i; }), /* { dg-warning "invalid in C\[+\]\[+\]" } */
18 D = __alignof__ (struct s4 { int i; }), /* { dg-warning "invalid in C\[+\]\[+\]" } */
22 struct s3 v3;
23 int v4 = C;
25 enum e3
27 F = sizeof (struct t3), /* { dg-bogus "invalid in C\[+\]\[+\]" } */
28 /* { dg-error "invalid application of 'sizeof'" "" { target *-*-* } 27 } */
29 G = __alignof__ (struct t4), /* { dg-bogus "invalid in C\[+\]\[+\]" } */
30 /* { dg-error "invalid application of '__alignof__'" "" { target *-*-* } 29 } */
34 __typeof__ (struct s5 { int i; }) v5; /* { dg-warning "invalid in C\[+\]\[+\]" } */
35 __typeof__ (struct t5) w5; /* { dg-bogus "invalid in C\[+\]\[+\]" } */
37 int
38 f1 (struct s1 *p)
40 return ((struct s6 { int j; } *) p)->j; /* { dg-warning "invalid in C\[+\]\[+\]" } */
43 void *
44 f2 (struct s1 *p)
46 return ((struct t6 *) p); /* { dg-bogus "invalid in C\[+\]\[+\]" } */
49 int
50 f3 (struct s1 *p)
52 return (__extension__ (struct s7 { int j; } *)p)->j;
55 int
56 f4 ()
58 return (struct s8 { int i; }) { 0 }.i; /* { dg-warning "invalid in C\[+\]\[+\]" } */
61 void *
62 f5 ()
64 return &((struct t8) { }); /* { dg-warning "invalid in C\[+\]\[+\]" } */
67 /* { dg-error "invalid use of undefined type" "" { target *-*-* } 64 } */