xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/crash-invalid-array.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -O1 %s -emit-llvm
2*f4a2713aSLionel Sambuc // PR6913
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc #include <stdio.h>
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc int main()
7*f4a2713aSLionel Sambuc {
8*f4a2713aSLionel Sambuc    int x[10][10];
9*f4a2713aSLionel Sambuc    int (*p)[] = x; // expected-error {{invalid use of array with unspecified bounds}
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc    int i;
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc    for(i = 0; i < 10; ++i)
14*f4a2713aSLionel Sambuc    {
15*f4a2713aSLionel Sambuc        p[i][i] = i;
16*f4a2713aSLionel Sambuc    }
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc // rdar://13705391
20*f4a2713aSLionel Sambuc void foo(int a[*][2]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
21*f4a2713aSLionel Sambuc void foo1(int a[2][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
22*f4a2713aSLionel Sambuc void foo2(int a[*][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
23*f4a2713aSLionel Sambuc void foo3(int a[2][*][2]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
24*f4a2713aSLionel Sambuc void foo4(int a[2][*][*]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
25