xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/crash-invalid-array.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
2f4a2713aSLionel Sambuc // PR6913
3f4a2713aSLionel Sambuc 
main()4f4a2713aSLionel Sambuc int main()
5f4a2713aSLionel Sambuc {
6f4a2713aSLionel Sambuc    int x[10][10];
7*0a6a1f1dSLionel Sambuc    int (*p)[] = x;
8f4a2713aSLionel Sambuc 
9f4a2713aSLionel Sambuc    int i;
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc    for(i = 0; i < 10; ++i)
12f4a2713aSLionel Sambuc    {
13*0a6a1f1dSLionel Sambuc        p[i][i] = i; // expected-error {{subscript of pointer to incomplete type 'int []'}}
14f4a2713aSLionel Sambuc    }
15f4a2713aSLionel Sambuc }
16f4a2713aSLionel Sambuc 
17f4a2713aSLionel Sambuc // rdar://13705391
foo(int a[* ][2])18f4a2713aSLionel Sambuc void foo(int a[*][2]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
foo1(int a[2][* ])19f4a2713aSLionel Sambuc void foo1(int a[2][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
foo2(int a[* ][* ])20f4a2713aSLionel Sambuc void foo2(int a[*][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
foo3(int a[2][* ][2])21f4a2713aSLionel Sambuc void foo3(int a[2][*][2]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
foo4(int a[2][* ][* ])22f4a2713aSLionel Sambuc void foo4(int a[2][*][*]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
23