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