diagnostics: add support for nested diagnostics [PR116253]
[official-gcc.git] / gcc / testsuite / gcc.dg / pr60257.c
blob46c29b0543f986f76c02b28ba6feaca46b66c572
1 /* PR c/60257 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wc++-compat -Woverride-init" } */
4 /* { dg-prune-output ".*near initialization for.*" } */
6 enum E1 { A };
7 enum E2 { B };
9 struct S
11 enum E1 e: 3;
14 struct S s[] =
16 { B } /* { dg-warning "5:enum conversion in initialization is invalid in C\[+\]\[+\]" } */
19 union U {
20 int i;
21 long long int l;
24 struct R {
25 int a;
28 void
29 foo (int i)
31 union U u = { .i = ++i, .l = 1 }; /* { dg-warning "32:initialized field with side-effects overwritten" } */
32 union U u2 = { .i = 1, .l = 3 }; /* { dg-warning "31:initialized field overwritten" } */
33 int a[] = { i++, [0] = 1 }; /* { dg-warning "26:initialized field with side-effects overwritten" } */
34 int a2[] = { i, [0] = 1 }; /* { dg-warning "25:initialized field overwritten" } */
35 struct R r = { 1, .a = 2 }; /* { dg-warning "26:initialized field overwritten" } */
36 struct R r2 = { ++i, .a = 2 }; /* { dg-warning "29:initialized field with side-effects overwritten" } */