Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/g++.dg/init/array53.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/g++.dg/init/array53.C Thu Feb 13 11:34:05 2020 +0900 @@ -0,0 +1,33 @@ +// PR c++/90947 - Simple lookup table of array of strings is miscompiled +// Verify that initializers for arrays of elements of a class type with +// "unusual" data members are correctly recognized as non-zero. +// { dg-do compile } +// { dg-options "-O1 -fdump-tree-optimized" } + +struct S +{ + const char *p; + static int i; + enum { e }; + typedef int X; + int: 1, b:1; + union { + int c; + }; + const char *q; +}; + +void f (void) +{ + const struct S a[2] = + { + { /* .p = */ "", /* .b = */ 0, /* .c = */ 0, /* .q = */ "" }, + { /* .p = */ "", /* .b = */ 0, /* .c = */ 0, /* .q = */ "" } + }; + + if (!a[0].p || *a[0].p || !a[0].q || *a[0].q + || !a[1].p || *a[1].p || !a[1].q || *a[1].q) + __builtin_abort (); +} + +// { dg-final { scan-tree-dump-not "abort" "optimized" } }