view gcc/testsuite/g++.dg/ext/flexary2.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

// PR c++/46688 - [4.6 Regression] g++ requires a function declaration
// when it should not
// Note that although the definition of struct B in the test case for
// c++/46688 was thought to be valid, it is, in fact, invalid, in C and
// as noted in c++/42121, should be treated as invalid in C++ as well.
// The test verifies that gcc detects and reports the right error.

// { dg-options "" }

struct A {
  A(int);
};

struct B {
  B() {}
  A a[];   // { dg-error "extension|flexible array .* in an otherwise empty" }
};

struct C {
  C() {}
  A a[0];  // -Wpedantic warning: ISO C++ forbids zero-size arrays
};