OSDN Git Service

PR/51443
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / Wcxx-compat-8.c
1 /* { dg-do compile } */
2 /* { dg-options "-Wc++-compat" } */
3
4 struct s1
5 {
6   enum e1       /* { dg-message "note: enum type defined here" } */
7   {
8     A = sizeof (struct s2 { int i; }),  /* { dg-warning "invalid in C\[+\]\[+\]" } */
9     B
10   } f1;
11 };
12 struct s2 v1;   /* Don't issue another warning about s2.  */
13 enum e1 v2;     /* { dg-warning "not visible in C\[+\]\[+\]" } */
14
15 enum e2
16 {
17   C = sizeof (struct s3 { int i; }),    /* { dg-warning "invalid in C\[+\]\[+\]" } */
18   D = __alignof__ (struct s4 { int i; }), /* { dg-warning "invalid in C\[+\]\[+\]" } */
19   E
20 };
21
22 struct s3 v3;
23 int v4 = C;
24
25 enum e3
26 {
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 } */
31   H
32 };
33
34 __typeof__ (struct s5 { int i; }) v5; /* { dg-warning "invalid in C\[+\]\[+\]" } */
35 __typeof__ (struct t5) w5; /* { dg-bogus "invalid in C\[+\]\[+\]" } */
36
37 int
38 f1 (struct s1 *p)
39 {
40   return ((struct s6 { int j; } *) p)->j;  /* { dg-warning "invalid in C\[+\]\[+\]" } */
41 }
42
43 void *
44 f2 (struct s1 *p)
45 {
46   return ((struct t6 *) p);  /* { dg-bogus "invalid in C\[+\]\[+\]" } */
47 }
48
49 int
50 f3 (struct s1 *p)
51 {
52   return (__extension__ (struct s7 { int j; } *)p)->j;
53 }
54
55 int
56 f4 ()
57 {
58   return (struct s8 { int i; }) { 0 }.i;  /* { dg-warning "invalid in C\[+\]\[+\]" } */
59 }
60
61 void *
62 f5 ()
63 {
64   return &((struct t8) { });  /* { dg-warning "invalid in C\[+\]\[+\]" } */
65 }