summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/vla1.C
blob: f3725354fc3e607fbf284f549ecb1826b4ffc223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// { 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 "variable length array" }

  ar[0][0] = 0;
}

class B { B (int); };

B::B (int i)
{
  struct S {
    int ar[1][i];  // { dg-error "array" }
  } s;

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