| 1 |
// RUN: %clang_cc1 -std=c++11 -verify %s |
| 2 |
|
| 3 |
union U { |
| 4 |
int x = 0; // expected-note {{previous initialization is here}} |
| 5 |
union {}; // expected-warning {{does not declare anything}} |
| 6 |
union { |
| 7 |
int z; |
| 8 |
int y = 1; // expected-error {{initializing multiple members of union}} |
| 9 |
}; |
| 10 |
}; |
| 11 |
|
| 12 |
namespace GH149985 { |
| 13 |
union X { |
| 14 |
enum { |
| 15 |
csize = 42, |
| 16 |
cs = sizeof(int) // expected-note {{previous declaration is here}} |
| 17 |
}; |
| 18 |
struct { |
| 19 |
int data; // expected-note {{previous declaration is here}} |
| 20 |
union X *cs[csize] = {}; // expected-error {{member of anonymous struct redeclares}} expected-note {{previous initialization is here}} |
| 21 |
}; |
| 22 |
struct { |
| 23 |
int data; // expected-error {{member of anonymous struct redeclares}} |
| 24 |
union X *ds[2] = {}; // expected-error {{initializing multiple members of union}} |
| 25 |
}; |
| 26 |
}; |
| 27 |
|
| 28 |
union U { |
| 29 |
int x; // expected-note {{previous declaration is here}} |
| 30 |
union { |
| 31 |
int x = {}; // expected-error {{member of anonymous union redeclares}} expected-note {{previous initialization is here}} |
| 32 |
}; |
| 33 |
int y = {}; // expected-error {{initializing multiple members of union}} |
| 34 |
}; |
| 35 |
} |