comparison gcc/testsuite/g++.dg/cpp2a/desig3.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 // { dg-do run { target c++17 } }
2 // { dg-options "-pedantic" }
3
4 struct S { int a; union { int b; double c; union { short e; long f; }; }; int d; };
5 S s = { 1, 2, 3 };
6 S t = { .a = 4, .b = 5, .d = 6 }; // { dg-warning "designated initializers only available with" "" { target c++17_down } }
7 S u = { .a = 7, .c = 8.0, .d = 9 }; // { dg-warning "designated initializers only available with" "" { target c++17_down } }
8 S v = { .c = 10.0, .d = 11 }; // { dg-warning "designated initializers only available with" "" { target c++17_down } }
9 S w = { .b = 12 }; // { dg-warning "designated initializers only available with" "" { target c++17_down } }
10 S x = { .b = 13 }; // { dg-warning "designated initializers only available with" "" { target c++17_down } }
11 S y = { .a = 14, .e = 15, .d = 16 }; // { dg-warning "designated initializers only available with" "" { target c++17_down } }
12 S z = { .f = 17 }; // { dg-warning "designated initializers only available with" "" { target c++17_down } }
13
14 int
15 main ()
16 {
17 if (s.a != 1 || s.b != 2 || s.d != 3
18 || t.a != 4 || t.b != 5 || t.d != 6
19 || u.a != 7 || u.c != 8.0 || u.d != 9
20 || v.a != 0 || v.c != 10.0 || v.d != 11
21 || w.a != 0 || w.b != 12 || w.d != 0
22 || x.a != 0 || x.b != 13 || x.d != 0
23 || y.a != 14 || y.e != 15 || y.d != 16
24 || z.a != 0 || z.f != 17 || z.d != 0)
25 __builtin_abort ();
26 return 0;
27 }