| 1 |
// PR c++/90947 - Simple lookup table of array of strings is miscompiled |
| 2 |
// Verify that initializers for arrays of elements of a class type with |
| 3 |
// "unusual" data members are correctly recognized as non-zero. |
| 4 |
// { dg-do compile } |
| 5 |
// { dg-options "-O1 -fdump-tree-optimized" } |
| 6 |
|
| 7 |
struct S |
| 8 |
{ |
| 9 |
const char *p; |
| 10 |
static int i; |
| 11 |
enum { e }; |
| 12 |
typedef int X; |
| 13 |
int: 1, b:1; |
| 14 |
union { |
| 15 |
int c; |
| 16 |
}; |
| 17 |
const char *q; |
| 18 |
}; |
| 19 |
|
| 20 |
void f (void) |
| 21 |
{ |
| 22 |
const struct S a[2] = |
| 23 |
{ |
| 24 |
{ /* .p = */ "", /* .b = */ 0, /* .c = */ 0, /* .q = */ "" }, |
| 25 |
{ /* .p = */ "", /* .b = */ 0, /* .c = */ 0, /* .q = */ "" } |
| 26 |
}; |
| 27 |
|
| 28 |
if (!a[0].p || *a[0].p || !a[0].q || *a[0].q |
| 29 |
|| !a[1].p || *a[1].p || !a[1].q || *a[1].q) |
| 30 |
__builtin_abort (); |
| 31 |
} |
| 32 |
|
| 33 |
// { dg-final { scan-tree-dump-not "abort" "optimized" } } |