2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 %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 };
|
2010-02-14 09:03:10 +08:00
|
|
|
xyz b; // expected-error {{must use 'struct' tag to refer to type 'xyz'}}
|
|
|
|
myenum c; // expected-error {{must use 'enum' tag to refer to type 'myenum'}}
|
2009-04-13 05:49:30 +08:00
|
|
|
|
|
|
|
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");
|
2010-02-02 08:37:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
struct test9 {
|
|
|
|
int x // expected-error {{expected ';' at end of declaration list}}
|
|
|
|
int y;
|
|
|
|
int z // expected-warning {{expected ';' at end of declaration list}}
|
|
|
|
};
|
2010-02-03 01:32:27 +08:00
|
|
|
|
|
|
|
// PR6208
|
|
|
|
struct test10 { int a; } static test10x;
|
|
|
|
struct test11 { int a; } const test11x;
|
2010-02-03 09:45:03 +08:00
|
|
|
|
|
|
|
// PR6216
|
|
|
|
void test12() {
|
|
|
|
(void)__builtin_offsetof(struct { char c; int i; }, i);
|
|
|
|
}
|
2010-02-04 04:41:24 +08:00
|
|
|
|
|
|
|
// rdar://7608537
|
|
|
|
struct test13 { int a; } (test13x);
|