Files
clang-p2996/clang/test/Sema/array-constraint.c
Chris Lattner 9bad62c72a Merge all the 'assignment' diagnostic code into one routine, decloning
it from several places.  This merges the diagnostics, making them more
uniform and fewer in number. This also simplifies and cleans up the code.

Some highlights:
1. This removes a bunch of very-similar diagnostics.
2. This renames AssignmentCheckResult -> AssignConvertType
3. This merges PointerFromInt + IntFromPointer which were always treated the same.
4. This updates a bunch of test cases that have minor changes to the produced diagnostics.

llvm-svn: 45589
2008-01-04 18:04:52 +00:00

52 lines
1.3 KiB
C

// RUN: clang -fsyntax-only -verify -pedantic %s
struct s;
struct s* t (struct s z[]) { // expected-error {{array has incomplete element type}}
return z;
}
void ff() {
struct s v, *p; // expected-error {{variable has incomplete type 'struct s'}}
p = &v;
}
void *k (void l[2]) { // expected-error {{array has incomplete element type}}
return l;
}
struct vari {
int a;
int b[];
};
struct vari *func(struct vari a[]) { // expected-error {{'struct vari' may not be used as an array element due to flexible array member}}
return a;
}
int foo[](void); // expected-error {{'foo' declared as array of functions}}
typedef int (*pfunc)(void);
pfunc xx(int f[](void)) { // expected-error {{'f' declared as array of functions}}
return f;
}
void check_size() {
float f;
int size_not_int[f]; // expected-error {{size of array has non-integer type 'float'}}
int negative_size[1-2]; // expected-error{{array size is negative}}
int zero_size[0]; // expected-warning{{zero size arrays are an extension}}
}
static int I;
typedef int TA[I]; // expected-error {{variable length array declared outside of any function}}
void strFunc(char *);
const char staticAry[] = "test";
int checkStaticAry() {
strFunc(staticAry); // expected-warning{{passing 'char const [5]' discards qualifiers, expected 'char *'}}
}