| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
|
| 3 |
enum struct a : int { |
| 4 |
one, two |
| 5 |
}; |
| 6 |
|
| 7 |
constexpr int fn () { return 42; } |
| 8 |
|
| 9 |
struct foo { |
| 10 |
int e1, e2; |
| 11 |
a e3; |
| 12 |
} arr[] = { |
| 13 |
{ 1, 2, a::one }, |
| 14 |
{ 3, a::two }, // { dg-error "11: cannot convert 'a' to 'int' in initialization" } |
| 15 |
{ 6, 7, 8 }, // { dg-error "11: cannot convert 'int' to 'a' in initialization" } |
| 16 |
{ 6, 7, fn() }, // { dg-error "13: cannot convert 'int' to 'a' in initialization" } |
| 17 |
}; |
| 18 |
|
| 19 |
struct bar { |
| 20 |
const char *f1; |
| 21 |
int f2; |
| 22 |
} arr_2[] = { |
| 23 |
{ "hello world", 42 }, |
| 24 |
{ 42 }, // { dg-error "5: invalid conversion from 'int' to 'const char\\*'" } |
| 25 |
{ "hello", "world" }, // { dg-error "14: invalid conversion from 'const char\\*' to 'int'" } |
| 26 |
}; |