| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
// { dg-options "-fdiagnostics-show-caret" } |
| 3 |
|
| 4 |
enum struct a : int { |
| 5 |
one, two |
| 6 |
}; |
| 7 |
|
| 8 |
constexpr int fn () { return 42; } |
| 9 |
|
| 10 |
struct foo { |
| 11 |
int e1, e2; |
| 12 |
a e3; |
| 13 |
} arr[] = { |
| 14 |
{ 3, a::two }, // { dg-error "11: cannot convert 'a' to 'int' in initialization" } |
| 15 |
/* { dg-begin-multiline-output "" } |
| 16 |
{ 3, a::two }, |
| 17 |
~~~^~~ |
| 18 |
| |
| 19 |
a |
| 20 |
{ dg-end-multiline-output "" } */ |
| 21 |
{ 6, 7, fn() }, // { dg-error "13: cannot convert 'int' to 'a' in initialization" } |
| 22 |
/* { dg-begin-multiline-output "" } |
| 23 |
{ 6, 7, fn() }, |
| 24 |
~~^~ |
| 25 |
| |
| 26 |
int |
| 27 |
{ dg-end-multiline-output "" } */ |
| 28 |
}; |
| 29 |
|
| 30 |
struct bar { |
| 31 |
const char *f1; |
| 32 |
int f2; |
| 33 |
} arr_2[] = { |
| 34 |
{ 42 }, // { dg-error "5: invalid conversion from 'int' to 'const char\\*'" } |
| 35 |
/* { dg-begin-multiline-output "" } |
| 36 |
{ 42 }, |
| 37 |
^~ |
| 38 |
| |
| 39 |
int |
| 40 |
{ dg-end-multiline-output "" } */ |
| 41 |
}; |