view gcc/testsuite/g++.dg/ext/vla1.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
line wrap: on
line source

// { dg-do compile }

// Crash tests from PR middle-end/6994.  See also gcc.dg/vla-2.c.
// A::A is acceptable extended C++ (VLA types brought over from C99);
// B::B is not, but is closely related to acceptable extended C, though
// not to acceptable C99.

class A { A (int); };

A::A (int i)
{
  int ar[1][i];    // { dg-error "7:ISO C\\+\\+ forbids variable length array .ar" }

  ar[0][0] = 0;
}

class B { B (int); };

B::B (int i)
{
  struct S {
    int ar[1][i];  // { dg-error "15:size of array .ar. is not an integral" "" { target c++11 } }
// { dg-error "array bound" "" { target c++98_only } .-1 }
  } s;

  s.ar[0][0] = 0;  // { dg-prune-output "no member" }
}