1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -O0 -verify %s
2// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -pedantic-errors -DPE -O0 -verify %s
3
4# ifndef PE
5// expected-no-diagnostics
6# endif
7
8extern "C" int printf(const char*, ...);
9
10static int N;
11struct S {
12  S() __attribute__ ((nothrow))  { printf("%d: S()\n", ++N); }
13  ~S()  __attribute__ ((nothrow))  { printf("%d: ~S()\n", N--); }
14  int n[17];
15};
16
17void print(int n, int a, int b, int c, int d) {
18  printf("n=%d\n,sizeof(S)=%d\nsizeof(array_t[0][0])=%d\nsizeof(array_t[0])=%d\nsizeof(array_t)=%d\n",
19         n, a, b, c, d);
20  if (n == 2) throw(n);
21}
22
23void test(int n) {
24  S array_t[n][n+1];
25# ifdef PE
26   // expected-error@-2 {{variable length arrays are a C99 feature}}
27   // expected-error@-3 {{variable length arrays are a C99 feature}}
28# endif
29  int sizeof_S = sizeof(S);
30  int sizeof_array_t_0_0 = sizeof(array_t[0][0]);
31  int sizeof_array_t_0 = sizeof(array_t[0]);
32  int sizeof_array_t = sizeof(array_t);
33  print(n, sizeof_S, sizeof_array_t_0_0, sizeof_array_t_0, sizeof_array_t);
34}
35
36int main()
37{
38  try {
39    test(2);
40  } catch(int e) {
41    printf("expeption %d\n", e);
42  }
43  try {
44    test(3);
45  } catch(int e) {
46    printf("expeption %d", e);
47  }
48}
49