2009-12-15 23:14:24 +03:00
|
|
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
|
2007-07-11 21:01:13 +04:00
|
|
|
|
|
|
|
extern int a1[];
|
|
|
|
|
|
|
|
void f0();
|
|
|
|
void f1(int [*]);
|
|
|
|
void f2(int [const *]);
|
|
|
|
void f3(int [volatile const*]);
|
2008-04-05 10:32:51 +04:00
|
|
|
int f4(*XX)(void); /* expected-error {{cannot return}} expected-warning {{type specifier missing, defaults to 'int'}} */
|
2007-07-11 21:01:13 +04:00
|
|
|
|
|
|
|
char ((((*X))));
|
|
|
|
|
|
|
|
void (*signal(int, void (*)(int)))(int);
|
|
|
|
|
2009-04-13 02:12:26 +04:00
|
|
|
int aaaa, ***C, * const D, B(int);
|
2007-07-11 21:01:13 +04:00
|
|
|
|
|
|
|
int *A;
|
|
|
|
|
|
|
|
struct str;
|
|
|
|
|
2009-07-22 04:43:08 +04:00
|
|
|
void test2(int *P, int A) {
|
2007-07-11 21:01:13 +04:00
|
|
|
struct str;
|
|
|
|
|
|
|
|
// Hard case for array decl, not Array[*].
|
|
|
|
int Array[*(int*)P+A];
|
|
|
|
}
|
|
|
|
|
2008-04-06 10:47:48 +04:00
|
|
|
typedef int atype;
|
2009-07-22 04:43:08 +04:00
|
|
|
void test3(x,
|
|
|
|
atype /* expected-error {{unexpected type name 'atype': expected identifier}} */
|
|
|
|
) int x, atype; {}
|
2007-07-11 21:01:13 +04:00
|
|
|
|
2009-07-22 04:43:08 +04:00
|
|
|
void test4(x, x) int x; {} /* expected-error {{redefinition of parameter 'x'}} */
|
2008-04-06 10:50:56 +04:00
|
|
|
|
2008-11-11 09:13:16 +03:00
|
|
|
|
|
|
|
// PR3031
|
|
|
|
int (test5), ; // expected-error {{expected identifier or '('}}
|
|
|
|
|
2009-04-13 00:42:31 +04:00
|
|
|
|
|
|
|
|
|
|
|
// PR3963 & rdar://6759604 - test error recovery for mistyped "typenames".
|
|
|
|
|
2009-04-13 01:49:30 +04:00
|
|
|
foo_t *d; // expected-error {{unknown type name 'foo_t'}}
|
2009-04-13 02:12:26 +04:00
|
|
|
foo_t a; // expected-error {{unknown type name 'foo_t'}}
|
2009-04-13 01:49:30 +04: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 04:03:10 +03: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 01:49:30 +04: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.
|
2010-04-09 04:35:39 +04:00
|
|
|
return &b.y; // expected-warning {{incompatible pointer types returning 'int *' from a function with result type 'float *'}}
|
2009-04-13 01:49:30 +04:00
|
|
|
}
|
2009-04-13 00:42:31 +04:00
|
|
|
|
2009-04-13 02:12:26 +04:00
|
|
|
struct xyz test8() { return a; } // a should be be marked invalid, no diag.
|
|
|
|
|
2009-04-13 00:42:31 +04:00
|
|
|
|
2009-04-13 01:49:30 +04:00
|
|
|
// Verify that implicit int still works.
|
2009-04-13 00:42:31 +04: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 07:13:54 +04:00
|
|
|
__asm__("foo");
|
2010-02-02 03:37:27 +03: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-02 20:32:27 +03:00
|
|
|
|
|
|
|
// PR6208
|
|
|
|
struct test10 { int a; } static test10x;
|
|
|
|
struct test11 { int a; } const test11x;
|
2010-02-03 04:45:03 +03:00
|
|
|
|
|
|
|
// PR6216
|
|
|
|
void test12() {
|
|
|
|
(void)__builtin_offsetof(struct { char c; int i; }, i);
|
|
|
|
}
|
2010-02-03 23:41:24 +03:00
|
|
|
|
|
|
|
// rdar://7608537
|
|
|
|
struct test13 { int a; } (test13x);
|
2010-05-31 02:30:21 +04:00
|
|
|
|
|
|
|
// <rdar://problem/8044088>
|
|
|
|
struct X<foo::int> { }; // expected-error{{expected identifier or '('}}
|