2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / cpp2a / desig6.C
bloba2d0a1036a41a58e417bf254a457425bf02312e7
1 // { dg-do compile }
2 // { dg-options "" }
4 struct A { int x, z, y; };
5 struct B { int y, a, x; };
6 void f(A a, int);          // #1
7 void f(B b, ...);          // #2
8 void g(A a);               // #3        { dg-message "candidate:" }
9 void g(B b);               // #4        { dg-message "candidate:" }
10 void h() {
11   f({.x = 1, .y = 2}, 0);  // OK; calls #1
12                            // { dg-warning "extended initializer lists only available with" "" { target c++98_only } .-1 }
13   f({.y = 2, .x = 1}, 0);  // error: selects #1
14                            // { dg-error "designator order for field 'A::x' does not match declaration order in 'A'" "" { target *-*-* } .-1 }
15                            // { dg-warning "extended initializer lists only available with" "" { target c++98_only } .-2 }
16   f({.x = 1, .z = 2, .y = 3}, 0); // OK; calls #1
17                            // { dg-warning "extended initializer lists only available with" "" { target c++98_only } .-1 }
18   f({.y = 3, .a = 2, .x = 1}, 0); // OK; calls #2
19                            // { dg-warning "extended initializer lists only available with" "" { target c++98_only } .-1 }
20   g({.x = 1, .y = 2});     // error: ambiguous between #3 and #4
21                            // { dg-error "is ambiguous" "" { target *-*-* } .-1 }
22                            // { dg-warning "extended initializer lists only available with" "" { target c++98_only } .-2 }