Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/ext/flexary12.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
line wrap: on
line source
// PR c++/69290 - [6 Regression] g++ ICE on invalid initialization // of a flexible array member // { dg-do compile } // Suppress pedantic errors about initialization of a flexible array member. // { dg-options "-Wno-pedantic" } struct A { int a []; // { dg-error "flexible array member .A::a. in an otherwise empty .struct A." } }; void f1 () { // This is the meat of the test from c++/69290: struct A a = { "c" }; // { dg-error "invalid conversion from .const char\\*. to .int." } (void)&a; } // Exercise other forms of invalid initialization besides the one in the bug. struct B { int n; int a []; }; void f2 () { struct B b1 = { 0, "c" }; // { dg-error "invalid conversion from .const char\\*. to .int." } (void)&b1; const char s[] = "c"; struct B b2 = { 0, s }; // { dg-error "invalid conversion from .const char\\*. to .int." } (void)&b2; } struct D { int a []; // { dg-error "flexible array member .D::a. in an otherwise empty .struct D." } D (); }; D::D (): // { dg-error "initializer for flexible array member" } a ("c") // the initializer also has an invalid type but emitting // just the error above is sufficient { } template <class T> struct C { T a []; // { dg-error "flexible array member" } }; void f3 () { struct C<double> cd = { "c" }; // { dg-error "cannot convert .const char\\*. to .double." } (void)&cd; }