2009-03-24 10:24:46 +08:00
|
|
|
// RUN: clang-cc %s -fsyntax-only -verify -pedantic
|
2006-08-07 02:22:00 +08:00
|
|
|
|
2007-06-09 02:15:09 +08:00
|
|
|
extern int a1[];
|
2006-08-07 02:22:00 +08:00
|
|
|
|
|
|
|
void f0();
|
|
|
|
void f1(int [*]);
|
|
|
|
void f2(int [const *]);
|
|
|
|
void f3(int [volatile const*]);
|
2008-04-05 14:32:51 +08:00
|
|
|
int f4(*XX)(void); /* expected-error {{cannot return}} expected-warning {{type specifier missing, defaults to 'int'}} */
|
2006-08-07 02:22:00 +08:00
|
|
|
|
|
|
|
char ((((*X))));
|
|
|
|
|
|
|
|
void (*signal(int, void (*)(int)))(int);
|
|
|
|
|
2009-04-13 06:12:26 +08:00
|
|
|
int aaaa, ***C, * const D, B(int);
|
2006-08-07 02:22:00 +08:00
|
|
|
|
|
|
|
int *A;
|
|
|
|
|
2006-08-14 03:59:13 +08:00
|
|
|
struct str;
|
|
|
|
|
2009-07-22 08:43:08 +08:00
|
|
|
void test2(int *P, int A) {
|
2006-08-14 03:59:13 +08:00
|
|
|
struct str;
|
|
|
|
|
|
|
|
// Hard case for array decl, not Array[*].
|
2006-08-13 02:40:31 +08:00
|
|
|
int Array[*(int*)P+A];
|
|
|
|
}
|
2006-08-14 03:59:13 +08:00
|
|
|
|
2008-04-06 14:47:48 +08:00
|
|
|
typedef int atype;
|
2009-07-22 08:43:08 +08:00
|
|
|
void test3(x,
|
|
|
|
atype /* expected-error {{unexpected type name 'atype': expected identifier}} */
|
|
|
|
) int x, atype; {}
|
2006-08-14 03:59:13 +08:00
|
|
|
|
2009-07-22 08:43:08 +08:00
|
|
|
void test4(x, x) int x; {} /* expected-error {{redefinition of parameter 'x'}} */
|
2008-04-06 14:50:56 +08:00
|
|
|
|
2008-11-11 14:13:16 +08:00
|
|
|
|
|
|
|
// PR3031
|
|
|
|
int (test5), ; // expected-error {{expected identifier or '('}}
|
|
|
|
|
2009-04-13 04:42:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
// PR3963 & rdar://6759604 - test error recovery for mistyped "typenames".
|
|
|
|
|
2009-04-13 05:49:30 +08:00
|
|
|
foo_t *d; // expected-error {{unknown type name 'foo_t'}}
|
2009-04-13 06:12:26 +08:00
|
|
|
foo_t a; // expected-error {{unknown type name 'foo_t'}}
|
2009-04-13 05:49:30 +08:00
|
|
|
int test6() { return a; } // a should be declared.
|
|
|
|
|
|
|
|
// Use of tagged type without tag. rdar://6783347
|
|
|
|
struct xyz { int y; };
|
|
|
|
enum myenum { ASDFAS };
|
|
|
|
xyz b; // expected-error {{use of tagged type 'xyz' without 'struct' tag}}
|
|
|
|
myenum c; // expected-error {{use of tagged type 'myenum' without 'enum' tag}}
|
|
|
|
|
|
|
|
float *test7() {
|
|
|
|
// We should recover 'b' by parsing it with a valid type of "struct xyz", which
|
|
|
|
// allows us to diagnose other bad things done with y, such as this.
|
|
|
|
return &b.y; // expected-warning {{incompatible pointer types returning 'int *', expected 'float *'}}
|
|
|
|
}
|
2009-04-13 04:42:31 +08:00
|
|
|
|
2009-04-13 06:12:26 +08:00
|
|
|
struct xyz test8() { return a; } // a should be be marked invalid, no diag.
|
|
|
|
|
2009-04-13 04:42:31 +08:00
|
|
|
|
2009-04-13 05:49:30 +08:00
|
|
|
// Verify that implicit int still works.
|
2009-04-13 04:42:31 +08:00
|
|
|
static f; // expected-warning {{type specifier missing, defaults to 'int'}}
|
|
|
|
static g = 4; // expected-warning {{type specifier missing, defaults to 'int'}}
|
|
|
|
static h // expected-warning {{type specifier missing, defaults to 'int'}}
|
2009-04-28 11:13:54 +08:00
|
|
|
__asm__("foo");
|