aboutsummaryrefslogtreecommitdiff
path: root/test/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'test/Parser')
-rwxr-xr-xtest/Parser/2008-10-31-parse-noop-failure.c4
-rw-r--r--test/Parser/CompoundStmtScope.c8
-rw-r--r--test/Parser/MicrosoftExtensions.c30
-rw-r--r--test/Parser/argument_qualified.c5
-rw-r--r--test/Parser/argument_redef.c6
-rw-r--r--test/Parser/argument_scope.c6
-rw-r--r--test/Parser/asm.c15
-rw-r--r--test/Parser/attributes.c53
-rw-r--r--test/Parser/bad-control.c9
-rw-r--r--test/Parser/block-block-storageclass.c19
-rw-r--r--test/Parser/block-pointer-decl.c26
-rw-r--r--test/Parser/builtin_classify_type.c21
-rw-r--r--test/Parser/builtin_types_compatible.c43
-rw-r--r--test/Parser/c-namespace.c6
-rw-r--r--test/Parser/char-literal-printing.c31
-rw-r--r--test/Parser/check-objc2-syntax-1.m10
-rw-r--r--test/Parser/check-syntax-1.m4
-rw-r--r--test/Parser/check_cast.c12
-rw-r--r--test/Parser/compound_literal.c5
-rw-r--r--test/Parser/control-scope.c8
-rw-r--r--test/Parser/cxx-ambig-paren-expr.cpp26
-rw-r--r--test/Parser/cxx-bool.cpp4
-rw-r--r--test/Parser/cxx-casting.cpp36
-rw-r--r--test/Parser/cxx-class.cpp38
-rw-r--r--test/Parser/cxx-condition.cpp11
-rw-r--r--test/Parser/cxx-decl.cpp3
-rw-r--r--test/Parser/cxx-exception-spec.cpp17
-rw-r--r--test/Parser/cxx-friend.cpp17
-rw-r--r--test/Parser/cxx-namespace-alias.cpp8
-rw-r--r--test/Parser/cxx-reference.cpp21
-rw-r--r--test/Parser/cxx-template-decl.cpp82
-rw-r--r--test/Parser/cxx-throw.cpp15
-rw-r--r--test/Parser/cxx-try.cpp41
-rw-r--r--test/Parser/cxx-typeid.cpp13
-rw-r--r--test/Parser/cxx-typeof.cpp7
-rw-r--r--test/Parser/cxx-using-directive.cpp41
-rw-r--r--test/Parser/cxx-variadic-func.cpp5
-rw-r--r--test/Parser/cxx0x-rvalue-reference.cpp9
-rw-r--r--test/Parser/declarators.c66
-rw-r--r--test/Parser/designator.c17
-rw-r--r--test/Parser/encode.m8
-rw-r--r--test/Parser/enhanced-proto-1.m17
-rw-r--r--test/Parser/expressions.c50
-rw-r--r--test/Parser/expressions.m6
-rw-r--r--test/Parser/extension.c20
-rw-r--r--test/Parser/function-decls.c10
-rw-r--r--test/Parser/goto-ident.c6
-rw-r--r--test/Parser/if-scope-c90.c8
-rw-r--r--test/Parser/if-scope-c99.c8
-rw-r--r--test/Parser/implicit-casts.c20
-rw-r--r--test/Parser/method-prototype-1.m43
-rw-r--r--test/Parser/namelookup-bug-1.c7
-rw-r--r--test/Parser/namelookup-bug-2.c14
-rw-r--r--test/Parser/objc-alias-printing.m18
-rw-r--r--test/Parser/objc-category-neg-1.m8
-rw-r--r--test/Parser/objc-forcollection-1.m43
-rw-r--r--test/Parser/objc-forcollection-neg-2.m38
-rw-r--r--test/Parser/objc-forcollection-neg.m37
-rw-r--r--test/Parser/objc-foreach-syntax.m26
-rw-r--r--test/Parser/objc-init.m41
-rw-r--r--test/Parser/objc-interfaces.m8
-rw-r--r--test/Parser/objc-messaging-1.m19
-rw-r--r--test/Parser/objc-messaging-neg-1.m7
-rw-r--r--test/Parser/objc-missing-impl.m2
-rw-r--r--test/Parser/objc-property-syntax.m12
-rw-r--r--test/Parser/objc-quirks.m10
-rw-r--r--test/Parser/objc-try-catch-1.m68
-rw-r--r--test/Parser/objc-type-printing.m19
-rw-r--r--test/Parser/parmvardecl_conversion.c4
-rw-r--r--test/Parser/pointer-arithmetic.c9
-rw-r--r--test/Parser/pointer_promotion.c18
-rw-r--r--test/Parser/pragma-pack.c32
-rw-r--r--test/Parser/prefix-attributes.m8
-rw-r--r--test/Parser/promote_types_in_proto.c9
-rw-r--r--test/Parser/recovery.c75
-rw-r--r--test/Parser/selector-1.m14
-rw-r--r--test/Parser/statements.c56
-rw-r--r--test/Parser/struct-recursion.c11
-rw-r--r--test/Parser/traditional_arg_scope.c7
-rw-r--r--test/Parser/typeof.c19
-rw-r--r--test/Parser/types.c14
81 files changed, 1647 insertions, 0 deletions
diff --git a/test/Parser/2008-10-31-parse-noop-failure.c b/test/Parser/2008-10-31-parse-noop-failure.c
new file mode 100755
index 000000000000..0598ea7dc9e7
--- /dev/null
+++ b/test/Parser/2008-10-31-parse-noop-failure.c
@@ -0,0 +1,4 @@
+// RUN: clang-cc -verify -parse-noop %t
+
+void add_attribute(id) int id; {}
+
diff --git a/test/Parser/CompoundStmtScope.c b/test/Parser/CompoundStmtScope.c
new file mode 100644
index 000000000000..6a404aa3a2c6
--- /dev/null
+++ b/test/Parser/CompoundStmtScope.c
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int foo() {
+ {
+ typedef float X;
+ }
+ X Y; // expected-error {{use of undeclared identifier}}
+}
diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c
new file mode 100644
index 000000000000..6f5622e93932
--- /dev/null
+++ b/test/Parser/MicrosoftExtensions.c
@@ -0,0 +1,30 @@
+// RUN: clang-cc -fsyntax-only -verify -fms-extensions -x=objective-c++ %s
+__stdcall int func0();
+int __stdcall func();
+typedef int (__cdecl *tptr)();
+void (*__fastcall fastpfunc)();
+extern __declspec(dllimport) void __stdcall VarR4FromDec();
+__declspec(deprecated) __declspec(deprecated) char * __cdecl ltoa( long _Val, char * _DstBuf, int _Radix);
+__declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory );
+typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR;
+void * __ptr64 PtrToPtr64(const void *p)
+{
+ return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p );
+}
+__forceinline InterlockedBitTestAndSet (long *Base, long Bit) // expected-warning {{type specifier missing, defaults to 'int'}}
+{
+ __asm {
+ mov eax, Bit
+ mov ecx, Base
+ lock bts [ecx], eax
+ setc al
+ };
+}
+
+void *_alloca(int);
+
+void foo() {
+ __declspec(align(16)) int *buffer = (int *)_alloca(9);
+}
+
+typedef bool (__stdcall __stdcall *blarg)(int);
diff --git a/test/Parser/argument_qualified.c b/test/Parser/argument_qualified.c
new file mode 100644
index 000000000000..c9494e7373a0
--- /dev/null
+++ b/test/Parser/argument_qualified.c
@@ -0,0 +1,5 @@
+// RUN: clang-cc %s
+int abc (const float x) {
+ return 1;
+}
+
diff --git a/test/Parser/argument_redef.c b/test/Parser/argument_redef.c
new file mode 100644
index 000000000000..1a43178a40cd
--- /dev/null
+++ b/test/Parser/argument_redef.c
@@ -0,0 +1,6 @@
+/* RUN: clang-cc -fsyntax-only -verify %s
+*/
+
+int foo(int A) { /* expected-note {{previous definition is here}} */
+ int A; /* expected-error {{redefinition of 'A'}} */
+}
diff --git a/test/Parser/argument_scope.c b/test/Parser/argument_scope.c
new file mode 100644
index 000000000000..5e6f439cfdf8
--- /dev/null
+++ b/test/Parser/argument_scope.c
@@ -0,0 +1,6 @@
+// RUN: clang-cc -fsyntax-only %s
+typedef struct foo foo;
+
+void blah(int foo) {
+ foo = 1;
+}
diff --git a/test/Parser/asm.c b/test/Parser/asm.c
new file mode 100644
index 000000000000..9cf9046aab6a
--- /dev/null
+++ b/test/Parser/asm.c
@@ -0,0 +1,15 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+void f1() {
+ asm ("ret" : : :); // expected-error {{expected string literal}}
+}
+
+void f2() {
+ asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
+ asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}}
+}
+
+
+// rdar://5952468
+__asm ; // expected-error {{expected '(' after 'asm'}}
+
diff --git a/test/Parser/attributes.c b/test/Parser/attributes.c
new file mode 100644
index 000000000000..dc2bb02670c6
--- /dev/null
+++ b/test/Parser/attributes.c
@@ -0,0 +1,53 @@
+// RUN: clang-cc -fsyntax-only -verify %s -pedantic -std=c99
+
+int __attribute__(()) x;
+
+__inline void __attribute__((__always_inline__, __nodebug__))
+foo(void) {
+}
+
+
+__attribute__(()) y; // expected-warning {{defaults to 'int'}}
+
+// PR2796
+int (__attribute__(()) *z)(long y);
+
+
+void f1(__attribute__(()) int x);
+
+int f2(y, __attribute__(()) x); // expected-error {{expected identifier}}
+
+// This is parsed as a normal argument list (with two args that are implicit
+// int) because the __attribute__ is a declspec.
+void f3(__attribute__(()) x, // expected-warning {{defaults to 'int'}}
+ y); // expected-warning {{defaults to 'int'}}
+
+void f4(__attribute__(())); // expected-error {{expected parameter declarator}}
+
+
+// This is ok, the __attribute__ applies to the pointer.
+int baz(int (__attribute__(()) *x)(long y));
+
+void g1(void (*f1)(__attribute__(()) int x));
+void g2(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
+void g3(void (*f3)(__attribute__(()) x, int y)); // expected-warning {{defaults to 'int'}}
+void g4(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
+
+
+void (*h1)(void (*f1)(__attribute__(()) int x));
+void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
+
+void (*h3)(void (*f3)(__attribute__(()) x)); // expected-warning {{defaults to 'int'}}
+void (*h4)(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
+
+
+
+// rdar://6131260
+int foo42(void) {
+ int x, __attribute__((unused)) y, z;
+ return 0;
+}
+
+// rdar://6096491
+void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void);
+
diff --git a/test/Parser/bad-control.c b/test/Parser/bad-control.c
new file mode 100644
index 000000000000..6e59667c3549
--- /dev/null
+++ b/test/Parser/bad-control.c
@@ -0,0 +1,9 @@
+/* RUN: clang-cc -fsyntax-only -verify %s
+*/
+int foo() {
+ break; /* expected-error {{'break' statement not in loop or switch statement}} */
+}
+
+int foo2() {
+ continue; /* expected-error {{'continue' statement not in loop statement}} */
+}
diff --git a/test/Parser/block-block-storageclass.c b/test/Parser/block-block-storageclass.c
new file mode 100644
index 000000000000..d24ec5f1c698
--- /dev/null
+++ b/test/Parser/block-block-storageclass.c
@@ -0,0 +1,19 @@
+// RUN: clang-cc -fsyntax-only -verify -parse-noop %s
+#if 0
+#include <stdio.h>
+void _Block_byref_release(void*src){}
+
+int main() {
+ __block int X = 1234;
+ __block const char * message = "HELLO";
+
+ X = X - 1234;
+
+ X += 1;
+
+ printf ("%s(%d)\n", message, X);
+ X -= 1;
+
+ return X;
+}
+#endif
diff --git a/test/Parser/block-pointer-decl.c b/test/Parser/block-pointer-decl.c
new file mode 100644
index 000000000000..7a21651bad32
--- /dev/null
+++ b/test/Parser/block-pointer-decl.c
@@ -0,0 +1,26 @@
+// RUN: clang-cc -fsyntax-only -verify -parse-noop -fblocks %s
+
+struct blockStruct {
+ int (^a)(float, int);
+ int b;
+};
+
+int blockTaker (int (^myBlock)(int), int other_input)
+{
+ return 5 * myBlock (other_input);
+}
+
+int main (int argc, char **argv)
+{
+ int (^blockptr) (int) = ^(int inval) {
+ printf ("Inputs: %d, %d.\n", argc, inval);
+ return argc * inval;
+ };
+
+
+ argc = 10;
+ printf ("I got: %d.\n",
+ blockTaker (blockptr, 6));
+ return 0;
+}
+
diff --git a/test/Parser/builtin_classify_type.c b/test/Parser/builtin_classify_type.c
new file mode 100644
index 000000000000..7046310eb4a8
--- /dev/null
+++ b/test/Parser/builtin_classify_type.c
@@ -0,0 +1,21 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+struct foo { int a; };
+
+int main() {
+ int a;
+ float b;
+ double d;
+ struct foo s;
+
+ static int ary[__builtin_classify_type(a)];
+ static int ary2[(__builtin_classify_type)(a)]; // expected-error{{variable length array declaration can not have 'static' storage duration}}
+ static int ary3[(*__builtin_classify_type)(a)]; // expected-error{{variable length array declaration can not have 'static' storage duration}}
+
+ int result;
+
+ result = __builtin_classify_type(a);
+ result = __builtin_classify_type(b);
+ result = __builtin_classify_type(d);
+ result = __builtin_classify_type(s);
+}
diff --git a/test/Parser/builtin_types_compatible.c b/test/Parser/builtin_types_compatible.c
new file mode 100644
index 000000000000..0664a9f55641
--- /dev/null
+++ b/test/Parser/builtin_types_compatible.c
@@ -0,0 +1,43 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+extern int funcInt(int);
+extern float funcFloat(float);
+extern double funcDouble(double);
+// figure out why "char *" doesn't work (with gcc, nothing to do with clang)
+//extern void funcCharPtr(char *);
+
+#define func(expr) \
+ do { \
+ typeof(expr) tmp; \
+ if (__builtin_types_compatible_p(typeof(expr), int)) funcInt(tmp); \
+ else if (__builtin_types_compatible_p(typeof(expr), float)) funcFloat(tmp); \
+ else if (__builtin_types_compatible_p(typeof(expr), double)) funcDouble(tmp); \
+ } while (0)
+#define func_choose(expr) \
+ __builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), int), funcInt(expr), \
+ __builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), float), funcFloat(expr), \
+ __builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), double), funcDouble(expr), (void)0)))
+
+static void test()
+{
+ int a;
+ float b;
+ double d;
+
+ func(a);
+ func(b);
+ func(d);
+ a = func_choose(a);
+ b = func_choose(b);
+ d = func_choose(d);
+
+ int c;
+ struct xx { int a; } x, y;
+
+ c = __builtin_choose_expr(a+3-7, b, x); // expected-error{{'__builtin_choose_expr' requires a constant expression}}
+ c = __builtin_choose_expr(0, b, x); // expected-error{{incompatible type assigning 'struct xx', expected 'int'}}
+ c = __builtin_choose_expr(5+3-7, b, x);
+ y = __builtin_choose_expr(4+3-7, b, x);
+
+}
+
diff --git a/test/Parser/c-namespace.c b/test/Parser/c-namespace.c
new file mode 100644
index 000000000000..ffca15e6a2eb
--- /dev/null
+++ b/test/Parser/c-namespace.c
@@ -0,0 +1,6 @@
+// RUN: clang-cc -fsyntax-only %s
+void bla1() {
+ struct XXX;
+ int XXX;
+}
+
diff --git a/test/Parser/char-literal-printing.c b/test/Parser/char-literal-printing.c
new file mode 100644
index 000000000000..f6ad0ff511be
--- /dev/null
+++ b/test/Parser/char-literal-printing.c
@@ -0,0 +1,31 @@
+// RUN: clang-cc -ast-print %s
+
+#include <stddef.h>
+
+char test1(void) { return '\\'; }
+wchar_t test2(void) { return L'\\'; }
+char test3(void) { return '\''; }
+wchar_t test4(void) { return L'\''; }
+char test5(void) { return '\a'; }
+wchar_t test6(void) { return L'\a'; }
+char test7(void) { return '\b'; }
+wchar_t test8(void) { return L'\b'; }
+char test9(void) { return '\e'; }
+wchar_t test10(void) { return L'\e'; }
+char test11(void) { return '\f'; }
+wchar_t test12(void) { return L'\f'; }
+char test13(void) { return '\n'; }
+wchar_t test14(void) { return L'\n'; }
+char test15(void) { return '\r'; }
+wchar_t test16(void) { return L'\r'; }
+char test17(void) { return '\t'; }
+wchar_t test18(void) { return L'\t'; }
+char test19(void) { return '\v'; }
+wchar_t test20(void) { return L'\v'; }
+
+char test21(void) { return 'c'; }
+wchar_t test22(void) { return L'c'; }
+char test23(void) { return '\x3'; }
+wchar_t test24(void) { return L'\x3'; }
+
+wchar_t test25(void) { return L'\x333'; }
diff --git a/test/Parser/check-objc2-syntax-1.m b/test/Parser/check-objc2-syntax-1.m
new file mode 100644
index 000000000000..f596e9ba0f37
--- /dev/null
+++ b/test/Parser/check-objc2-syntax-1.m
@@ -0,0 +1,10 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+@interface Subclass
++ (int)magicNumber;
+@end
+
+int main (void) {
+ return Subclass.magicNumber;
+}
+
diff --git a/test/Parser/check-syntax-1.m b/test/Parser/check-syntax-1.m
new file mode 100644
index 000000000000..f4aa430cde18
--- /dev/null
+++ b/test/Parser/check-syntax-1.m
@@ -0,0 +1,4 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int @interface bla ; // expected-error {{cannot combine with previous 'int' declaration specifier}}
+@end
diff --git a/test/Parser/check_cast.c b/test/Parser/check_cast.c
new file mode 100644
index 000000000000..4df851c7bf9f
--- /dev/null
+++ b/test/Parser/check_cast.c
@@ -0,0 +1,12 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+struct foo {
+ int a;
+};
+
+int main() {
+ struct foo xxx;
+ int i;
+
+ xxx = (struct foo)1; // expected-error {{used type 'struct foo' where arithmetic or pointer type is required}}
+ i = (int)xxx; // expected-error {{operand of type 'struct foo' where arithmetic or pointer type is required}}
+}
diff --git a/test/Parser/compound_literal.c b/test/Parser/compound_literal.c
new file mode 100644
index 000000000000..c263763b2e2a
--- /dev/null
+++ b/test/Parser/compound_literal.c
@@ -0,0 +1,5 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+int main() {
+ char *s;
+ s = (char []){"whatever"};
+}
diff --git a/test/Parser/control-scope.c b/test/Parser/control-scope.c
new file mode 100644
index 000000000000..7ffc6ac46c0f
--- /dev/null
+++ b/test/Parser/control-scope.c
@@ -0,0 +1,8 @@
+// RUN: clang-cc %s -std=c90 -verify &&
+// RUN: clang-cc %s -std=c99
+
+int f (int z) {
+ if (z + sizeof (enum {a})) // expected-note {{previous definition is here}}
+ return 1 + sizeof (enum {a}); // expected-error {{redefinition of enumerator 'a'}}
+ return 0;
+}
diff --git a/test/Parser/cxx-ambig-paren-expr.cpp b/test/Parser/cxx-ambig-paren-expr.cpp
new file mode 100644
index 000000000000..6f23b35d3e6b
--- /dev/null
+++ b/test/Parser/cxx-ambig-paren-expr.cpp
@@ -0,0 +1,26 @@
+// RUN: clang-cc -fsyntax-only -pedantic -verify %s
+
+void f() {
+ typedef int T;
+ int x, *px;
+
+ // Type id.
+ (T())x; // expected-error {{used type 'T (void)'}}
+ (T())+x; // expected-error {{used type 'T (void)'}}
+ (T())*px; // expected-error {{used type 'T (void)'}}
+
+ // Expression.
+ x = (T());
+ x = (T())/x;
+
+ typedef int *PT;
+ // Make sure stuff inside the parens are parsed only once (only one warning).
+ x = (PT()[(int){1}]); // expected-warning {{compound literals}}
+
+ // Special case: empty parens is a call, not an expression
+ struct S{int operator()();};
+ (S())();
+
+ // FIXME: Special case: "++" is postfix here, not prefix
+ // (S())++;
+}
diff --git a/test/Parser/cxx-bool.cpp b/test/Parser/cxx-bool.cpp
new file mode 100644
index 000000000000..f0b3a9f9f038
--- /dev/null
+++ b/test/Parser/cxx-bool.cpp
@@ -0,0 +1,4 @@
+// RUN: clang-cc -fsyntax-only %s
+
+bool a = true;
+bool b = false;
diff --git a/test/Parser/cxx-casting.cpp b/test/Parser/cxx-casting.cpp
new file mode 100644
index 000000000000..1fdc28d2c880
--- /dev/null
+++ b/test/Parser/cxx-casting.cpp
@@ -0,0 +1,36 @@
+// RUN: clang-cc -fsyntax-only %s
+
+char *const_cast_test(const char *var)
+{
+ return const_cast<char*>(var);
+}
+
+#if 0
+// FIXME: Uncomment when C++ is supported more.
+struct A {
+ virtual ~A() {}
+};
+
+struct B : public A {
+};
+
+struct B *dynamic_cast_test(struct A *a)
+{
+ return dynamic_cast<struct B*>(a);
+}
+#endif
+
+char *reinterpret_cast_test()
+{
+ return reinterpret_cast<char*>(0xdeadbeef);
+}
+
+double static_cast_test(int i)
+{
+ return static_cast<double>(i);
+}
+
+char postfix_expr_test()
+{
+ return reinterpret_cast<char*>(0xdeadbeef)[0];
+}
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp
new file mode 100644
index 000000000000..ff452b919114
--- /dev/null
+++ b/test/Parser/cxx-class.cpp
@@ -0,0 +1,38 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+class C;
+class C {
+public:
+protected:
+ typedef int A,B;
+ static int sf(), u;
+
+ struct S {};
+ enum {};
+ int; // expected-error {{declaration does not declare anything}}
+ int : 1, : 2;
+
+public:
+ void m() {
+ int l = 2;
+ }
+ virtual int vf() const volatile = 0;
+
+private:
+ int x,f(),y,g();
+ inline int h();
+ static const int sci = 10;
+ mutable int mi;
+};
+void glo()
+{
+ struct local {};
+}
+
+// PR3177
+typedef union {
+ __extension__ union {
+ int a;
+ float b;
+ } y;
+} bug3177;
+
diff --git a/test/Parser/cxx-condition.cpp b/test/Parser/cxx-condition.cpp
new file mode 100644
index 000000000000..8fbca2a90f78
--- /dev/null
+++ b/test/Parser/cxx-condition.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-cc -parse-noop -verify %s
+
+void f() {
+ int a;
+ while (a) ;
+ while (int x) ; // expected-error {{expected '=' after declarator}}
+ while (float x = 0) ;
+ if (const int x = a) ;
+ switch (int x = a+10) {}
+ for (; int x = ++a; ) ;
+}
diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp
new file mode 100644
index 000000000000..3fa284282ad6
--- /dev/null
+++ b/test/Parser/cxx-decl.cpp
@@ -0,0 +1,3 @@
+// RUN: clang-cc -verify -fsyntax-only %s
+
+int x(*g); // expected-error {{use of undeclared identifier 'g'}}
diff --git a/test/Parser/cxx-exception-spec.cpp b/test/Parser/cxx-exception-spec.cpp
new file mode 100644
index 000000000000..0a87ab702302
--- /dev/null
+++ b/test/Parser/cxx-exception-spec.cpp
@@ -0,0 +1,17 @@
+// RUN: clang-cc -fsyntax-only %s
+
+struct X { };
+
+struct Y { };
+
+void f() throw() { }
+
+void g(int) throw(X) { }
+
+void h() throw(X, Y) { }
+
+class Class {
+ void foo() throw (X, Y) { }
+};
+
+void (*fptr)() throw();
diff --git a/test/Parser/cxx-friend.cpp b/test/Parser/cxx-friend.cpp
new file mode 100644
index 000000000000..ea30ddcbd0a8
--- /dev/null
+++ b/test/Parser/cxx-friend.cpp
@@ -0,0 +1,17 @@
+// RUN: clang-cc -fsyntax-only %s
+
+class C {
+ friend class D;
+};
+
+class A {
+public:
+ void f();
+};
+
+class B {
+ // 'A' here should refer to the declaration above.
+ friend class A;
+
+ void f(A *a) { a->f(); }
+};
diff --git a/test/Parser/cxx-namespace-alias.cpp b/test/Parser/cxx-namespace-alias.cpp
new file mode 100644
index 000000000000..65e1459d379b
--- /dev/null
+++ b/test/Parser/cxx-namespace-alias.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-cc -parse-noop -verify %s
+
+namespace A = B;
+
+namespace A = !; // expected-error {{expected namespace name}}
+namespace A = A::!; // expected-error {{expected namespace name}}
+
+
diff --git a/test/Parser/cxx-reference.cpp b/test/Parser/cxx-reference.cpp
new file mode 100644
index 000000000000..0d2b9d29c369
--- /dev/null
+++ b/test/Parser/cxx-reference.cpp
@@ -0,0 +1,21 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+extern char *bork;
+char *& bar = bork;
+
+int val;
+
+void foo(int &a) {
+}
+
+typedef int & A;
+
+void g(const A aref) {
+}
+
+int & const X = val; // expected-error {{'const' qualifier may not be applied to a reference}}
+int & volatile Y = val; // expected-error {{'volatile' qualifier may not be applied to a reference}}
+int & const volatile Z = val; /* expected-error {{'const' qualifier may not be applied}} \
+ expected-error {{'volatile' qualifier may not be applied}} */
+
+typedef int && RV; // expected-error {{rvalue references are only allowed in C++0x}}
diff --git a/test/Parser/cxx-template-decl.cpp b/test/Parser/cxx-template-decl.cpp
new file mode 100644
index 000000000000..ae5d8f9e0cce
--- /dev/null
+++ b/test/Parser/cxx-template-decl.cpp
@@ -0,0 +1,82 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// Errors
+export class foo { }; // expected-error {{expected template}}
+template x; // expected-error {{C++ requires a type specifier for all declarations}}
+export template x; // expected-error {{expected '<' after 'template'}} \
+ // expected-note {{exported templates are unsupported}} \
+// expected-error {{C++ requires a type specifier for all declarations}}
+// See Sema::ParsedFreeStandingDeclSpec about the double diagnostic. This is
+// because ParseNonTypeTemplateParameter starts parsing a DeclSpec.
+template < ; // expected-error {{parse error}} expected-error {{declaration does not declare anything}}
+template <template X> struct Err1; // expected-error {{expected '<' after 'template'}}
+template <template <typename> > struct Err2; // expected-error {{expected 'class' before '>'}}
+template <template <typename> Foo> struct Err3; // expected-error {{expected 'class' before 'Foo'}}
+
+// Template function declarations
+template <typename T> void foo();
+template <typename T, typename U> void foo();
+
+// Template function definitions.
+template <typename T> void foo() { }
+
+// Template class (forward) declarations
+template <typename T> struct A;
+template <typename T, typename U> struct b;
+template <typename> struct C;
+template <typename, typename> struct D;
+
+// Forward declarations with default parameters?
+template <typename T = int> class X1;
+template <typename = int> class X2;
+
+// Forward declarations w/template template parameters
+template <template <typename> class T> class TTP1;
+template <template <typename> class> class TTP2;
+template <template <typename> class T = foo> class TTP3; // FIXME:expected-error{{template argument for template template parameter must be a template}}
+template <template <typename> class = foo> class TTP3; // FIXME:expected-error{{template argument for template template parameter must be a template}}
+template <template <typename X, typename Y> class T> class TTP5;
+
+// Forward declararations with non-type params
+template <int> class NTP0;
+template <int N> class NTP1;
+template <int N = 5> class NTP2;
+template <int = 10> class NTP3;
+template <unsigned int N = 12u> class NTP4;
+template <unsigned int = 12u> class NTP5;
+template <unsigned = 15u> class NTP6;
+template <typename T, T Obj> class NTP7;
+
+// Template class declarations
+template <typename T> struct A { };
+template <typename T, typename U> struct B { };
+
+// Template parameter shadowing
+template<typename T, // expected-note{{template parameter is declared here}}
+ typename T> // expected-error{{declaration of 'T' shadows template parameter}}
+ void shadow1();
+
+template<typename T> // expected-note{{template parameter is declared here}}
+void shadow2(int T); // expected-error{{declaration of 'T' shadows template parameter}}
+
+template<typename T> // expected-note{{template parameter is declared here}}
+class T { // expected-error{{declaration of 'T' shadows template parameter}}
+};
+
+template<int Size> // expected-note{{template parameter is declared here}}
+void shadow3(int Size); // expected-error{{declaration of 'Size' shadows template parameter}}
+
+// Non-type template parameters in scope
+template<int Size>
+void f(int& i) {
+ i = Size;
+ Size = i; // expected-error{{expression is not assignable}}
+}
+
+template<typename T>
+const T& min(const T&, const T&);
+
+void f2() {
+ int x;
+ A< typeof(x>1) > a;
+}
diff --git a/test/Parser/cxx-throw.cpp b/test/Parser/cxx-throw.cpp
new file mode 100644
index 000000000000..bcc49ec1b4fb
--- /dev/null
+++ b/test/Parser/cxx-throw.cpp
@@ -0,0 +1,15 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int i;
+
+void foo() {
+ (throw,throw);
+ (1 ? throw 1 : throw 2);
+ throw int(1);
+ throw;
+ throw 1;
+ throw;
+ 1 ? throw : (void)42;
+ __extension__ throw 1; // expected-error {{expected expression}}
+ (void)throw; // expected-error {{expected expression}}
+}
diff --git a/test/Parser/cxx-try.cpp b/test/Parser/cxx-try.cpp
new file mode 100644
index 000000000000..535f40d78057
--- /dev/null
+++ b/test/Parser/cxx-try.cpp
@@ -0,0 +1,41 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+void f()
+{
+ try {
+ ;
+ } catch(int i) {
+ ;
+ } catch(...) {
+ }
+}
+
+void g()
+{
+ try; // expected-error {{expected '{'}}
+
+ try {}
+ catch; // expected-error {{expected '('}}
+
+ try {}
+ catch (...); // expected-error {{expected '{'}}
+
+ try {}
+ catch {} // expected-error {{expected '('}}
+}
+
+void h() try {
+} catch(...) {
+}
+
+struct A {
+ int i;
+ A(int);
+ A(char);
+ A() try : i(0) {} catch(...) {}
+ void f() try {} catch(...) {}
+ A(float) : i(0) try {} // expected-error {{expected '{' or ','}}
+};
+
+A::A(char) : i(0) try {} // expected-error {{expected '{' or ','}}
+A::A(int j) try : i(j) {} catch(...) {}
diff --git a/test/Parser/cxx-typeid.cpp b/test/Parser/cxx-typeid.cpp
new file mode 100644
index 000000000000..5a92e7322f1f
--- /dev/null
+++ b/test/Parser/cxx-typeid.cpp
@@ -0,0 +1,13 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// FIXME: This should really include <typeinfo>, but we don't have that yet.
+namespace std {
+ class type_info;
+}
+
+void f()
+{
+ (void)typeid(int);
+ (void)typeid(0);
+ (void)typeid 1; // expected-error {{error: expected '(' after 'typeid'}}
+}
diff --git a/test/Parser/cxx-typeof.cpp b/test/Parser/cxx-typeof.cpp
new file mode 100644
index 000000000000..0bf446316cfc
--- /dev/null
+++ b/test/Parser/cxx-typeof.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+static void test() {
+ int *pi;
+ int x;
+ typeof pi[x] y;
+}
diff --git a/test/Parser/cxx-using-directive.cpp b/test/Parser/cxx-using-directive.cpp
new file mode 100644
index 000000000000..676f4e6c5a5e
--- /dev/null
+++ b/test/Parser/cxx-using-directive.cpp
@@ -0,0 +1,41 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+class A {};
+
+namespace B {
+ namespace A {}
+ using namespace A ;
+}
+
+namespace C {}
+
+namespace D {
+
+ class C {
+
+ using namespace B ; // expected-error{{expected member name or ';' after declaration specifiers}}
+ //FIXME: this needs better error message
+ };
+
+ namespace B {}
+
+ using namespace C ;
+ using namespace B::A ; // expected-error{{expected namespace name}}
+ //FIXME: would be nice to note, that A is not member of D::B
+ using namespace ::B::A ;
+ using namespace ::D::C ; // expected-error{{expected namespace name}}
+}
+
+using namespace ! ; // expected-error{{expected namespace name}}
+using namespace A ; // expected-error{{expected namespace name}}
+using namespace ::A // expected-error{{expected namespace name}} \
+ // expected-error{{expected ';' after namespace name}}
+ B ;
+
+void test_nslookup() {
+ int B;
+ class C;
+ using namespace B;
+ using namespace C;
+}
+
diff --git a/test/Parser/cxx-variadic-func.cpp b/test/Parser/cxx-variadic-func.cpp
new file mode 100644
index 000000000000..86d6b6bf2c5d
--- /dev/null
+++ b/test/Parser/cxx-variadic-func.cpp
@@ -0,0 +1,5 @@
+// RUN: clang-cc -fsyntax-only %s
+
+void f(...) {
+ int g(int(...));
+}
diff --git a/test/Parser/cxx0x-rvalue-reference.cpp b/test/Parser/cxx0x-rvalue-reference.cpp
new file mode 100644
index 000000000000..389f2b947003
--- /dev/null
+++ b/test/Parser/cxx0x-rvalue-reference.cpp
@@ -0,0 +1,9 @@
+// RUN: clang-cc -fsyntax-only -verify -std=c++0x %s
+
+int && r1(int &&a);
+
+typedef int && R;
+void r2(const R a) {
+ int & &&ar = a; // expected-error{{'ar' declared as a reference to a reference}}
+}
+
diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c
new file mode 100644
index 000000000000..26e8027d1078
--- /dev/null
+++ b/test/Parser/declarators.c
@@ -0,0 +1,66 @@
+// RUN: clang-cc %s -fsyntax-only -verify -pedantic
+
+extern int a1[];
+
+void f0();
+void f1(int [*]);
+void f2(int [const *]);
+void f3(int [volatile const*]);
+int f4(*XX)(void); /* expected-error {{cannot return}} expected-warning {{type specifier missing, defaults to 'int'}} */
+
+char ((((*X))));
+
+void (*signal(int, void (*)(int)))(int);
+
+int aaaa, ***C, * const D, B(int);
+
+int *A;
+
+struct str;
+
+int test2(int *P, int A) {
+ struct str;
+
+ // Hard case for array decl, not Array[*].
+ int Array[*(int*)P+A];
+}
+
+typedef int atype;
+int test3(x,
+ atype /* expected-error {{unexpected type name 'atype': expected identifier}} */
+ ) int x, atype; {}
+
+int test4(x, x) int x; {} /* expected-error {{redefinition of parameter 'x'}} */
+
+
+// PR3031
+int (test5), ; // expected-error {{expected identifier or '('}}
+
+
+
+// PR3963 & rdar://6759604 - test error recovery for mistyped "typenames".
+
+foo_t *d; // expected-error {{unknown type name 'foo_t'}}
+foo_t a; // expected-error {{unknown type name 'foo_t'}}
+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 *'}}
+}
+
+struct xyz test8() { return a; } // a should be be marked invalid, no diag.
+
+
+// Verify that implicit int still works.
+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'}}
+ __asm__("foo");
diff --git a/test/Parser/designator.c b/test/Parser/designator.c
new file mode 100644
index 000000000000..76c2d435227f
--- /dev/null
+++ b/test/Parser/designator.c
@@ -0,0 +1,17 @@
+// RUN: clang-cc -fsyntax-only %s -verify -pedantic
+
+int X[] = {
+ [4]4, // expected-warning {{use of GNU 'missing =' extension in designator}}
+ [5] = 7
+};
+
+struct foo {
+ int arr[10];
+};
+
+struct foo Y[10] = {
+ [4] .arr [2] = 4,
+
+ // This is not the GNU array init designator extension.
+ [4] .arr [2] 4 // expected-error {{expected '=' or another designator}}
+};
diff --git a/test/Parser/encode.m b/test/Parser/encode.m
new file mode 100644
index 000000000000..1e088a011511
--- /dev/null
+++ b/test/Parser/encode.m
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int main(void) {
+ const char ch = @encode(char *)[2];
+ char c = @encode(char *)[2] + 4;
+ return c;
+}
+
diff --git a/test/Parser/enhanced-proto-1.m b/test/Parser/enhanced-proto-1.m
new file mode 100644
index 000000000000..1f42ec2efbb4
--- /dev/null
+++ b/test/Parser/enhanced-proto-1.m
@@ -0,0 +1,17 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+@protocol MyProto1
+@optional
+- (void) FOO;
+@optional
+- (void) FOO;
+@required
+- (void) REQ;
+@optional
+@end
+
+@protocol MyProto2 <MyProto1>
+- (void) FOO2;
+@optional
+- (void) FOO3;
+@end
diff --git a/test/Parser/expressions.c b/test/Parser/expressions.c
new file mode 100644
index 000000000000..2b4d4636ebb1
--- /dev/null
+++ b/test/Parser/expressions.c
@@ -0,0 +1,50 @@
+// RUN: clang-cc -parse-noop -verify %s
+
+void test1() {
+ if (sizeof (int){ 1}); // sizeof compound literal
+ if (sizeof (int)); // sizeof type
+
+ (int)4; // cast.
+ (int){4}; // compound literal.
+
+ // FIXME: change this to the struct version when we can.
+ //int A = (struct{ int a;}){ 1}.a;
+ int A = (int){ 1}.a;
+}
+
+int test2(int a, int b) {
+ return a ? a,b : a;
+}
+
+int test3(int a, int b, int c) {
+ return a = b = c;
+}
+
+int test4() {
+ test4();
+}
+
+int test_offsetof() {
+ // FIXME: change into something that is semantically correct.
+ __builtin_offsetof(int, a.b.c[4][5]);
+}
+
+void test_sizeof(){
+ int arr[10];
+ sizeof arr[0];
+ sizeof(arr[0]);
+ sizeof(arr)[0];
+}
+
+// PR3418
+int test_leading_extension() {
+ __extension__ (*(char*)0) = 1;
+}
+
+// PR3972
+int test5(int);
+int test6(void) {
+ return test5( // expected-note {{to match}}
+ test5(1)
+ ; // expected-error {{expected ')'}}
+}
diff --git a/test/Parser/expressions.m b/test/Parser/expressions.m
new file mode 100644
index 000000000000..e9e41216f986
--- /dev/null
+++ b/test/Parser/expressions.m
@@ -0,0 +1,6 @@
+// RUN: clang-cc -parse-noop %s
+
+void test1() {
+ @"s"; // expected-warning {{expression result unused}}
+}
+
diff --git a/test/Parser/extension.c b/test/Parser/extension.c
new file mode 100644
index 000000000000..519dc053c82f
--- /dev/null
+++ b/test/Parser/extension.c
@@ -0,0 +1,20 @@
+/* RUN: clang-cc %s -fsyntax-only -pedantic -verify -std=c89
+ */
+
+/* Top level extension marker. */
+
+__extension__ typedef struct
+{
+ long long int quot;
+ long long int rem;
+} lldiv_t;
+
+
+/* Decl/expr __extension__ marker. */
+void bar() {
+ __extension__ int i;
+ int j;
+ __extension__ (j = 10LL);
+ __extension__ j = 10LL; /* expected-warning {{'long long' is an extension}} */
+}
+
diff --git a/test/Parser/function-decls.c b/test/Parser/function-decls.c
new file mode 100644
index 000000000000..28bb5c2e18da
--- /dev/null
+++ b/test/Parser/function-decls.c
@@ -0,0 +1,10 @@
+/* RUN: clang-cc %s -ast-print
+ */
+
+void foo() {
+ int X;
+ X = sizeof(void (*(*)())());
+ X = sizeof(int(*)(int, float, ...));
+ X = sizeof(void (*(int arga, void (*argb)(double Y)))(void* Z));
+}
+
diff --git a/test/Parser/goto-ident.c b/test/Parser/goto-ident.c
new file mode 100644
index 000000000000..e8d1963e38c2
--- /dev/null
+++ b/test/Parser/goto-ident.c
@@ -0,0 +1,6 @@
+/* RUN: clang-cc -fsyntax-only -verify %s
+*/
+
+void foo() {
+ goto ; /* expected-error {{expected identifier}} */
+}
diff --git a/test/Parser/if-scope-c90.c b/test/Parser/if-scope-c90.c
new file mode 100644
index 000000000000..fdc75e9f10b0
--- /dev/null
+++ b/test/Parser/if-scope-c90.c
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -verify --std=c90 %s
+
+int f (int z)
+{
+ if (z > sizeof (enum {a, b}))
+ return a;
+ return b;
+}
diff --git a/test/Parser/if-scope-c99.c b/test/Parser/if-scope-c99.c
new file mode 100644
index 000000000000..37cd0e15ab8e
--- /dev/null
+++ b/test/Parser/if-scope-c99.c
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -verify --std=c99 %s
+
+int f (int z)
+{
+ if (z > sizeof (enum {a, b}))
+ return a;
+ return b; // expected-error{{use of undeclared identifier}}
+}
diff --git a/test/Parser/implicit-casts.c b/test/Parser/implicit-casts.c
new file mode 100644
index 000000000000..e7d20980da47
--- /dev/null
+++ b/test/Parser/implicit-casts.c
@@ -0,0 +1,20 @@
+// RUN: clang-cc -fsyntax-only -verify -pedantic %s
+_Complex double X;
+void test1(int c) {
+ X = 5;
+}
+void test2() {
+ int i;
+ double d = i;
+ double _Complex a = 5;
+
+ test1(a);
+ a = 5;
+ d = i;
+}
+int test3() {
+ int a[2];
+ a[0] = test3; // expected-warning{{incompatible pointer to integer conversion assigning 'int ()', expected 'int'}}
+}
+short x; void test4(char c) { x += c; }
+int y; void test5(char c) { y += c; }
diff --git a/test/Parser/method-prototype-1.m b/test/Parser/method-prototype-1.m
new file mode 100644
index 000000000000..1d535de8c140
--- /dev/null
+++ b/test/Parser/method-prototype-1.m
@@ -0,0 +1,43 @@
+// RUN: clang-cc %s -parse-noop
+@interface MyObject
+- (void) bycopy : (int) woodo, ... ;
+- (void) break : (int) woodo, ... ;
+- (void) enum : (int) woodo, ... ;
+- (void) struct : (int) woodo, ... ;
+- (void) union : (int) woodo, ... ;
+- (void) if : (int) woodo, int i, char chh, ... ;
+- (void) else : (int) woodo, ... ;
+- (void) while : (int) woodo, ... ;
+- (void) do : (int) woodo, ... ;
+- (void) for : (int) woodo, ... ;
+- (void) switch : (int) woodo, ... ;
+- (void) case : (int) woodo, ... ;
+- (void) default : (int) woodo, ... ;
+- (void) break : (int) woodo, ... ;
+- (void) continue : (int) woodo, ... ;
+- (void) return : (int) woodo, ... ;
+- (void) goto : (int) woodo, ... ;
+- (void) sizeof : (int) woodo, ... ;
+- (void) typeof : (int) woodo, ... ;
+- (void) __alignof : (int) woodo, ... ;
+- (void) unsigned : (int) woodo, ... ;
+- (void) long : (int) woodo, ... ;
+- (void) const : (int) woodo, ... ;
+- (void) short : (int) woodo, ... ;
+- (void) volatile : (int) woodo, ... ;
+- (void) signed : (int) woodo, ... ;
+- (void) restrict : (int) woodo, ... ;
+- (void) _Complex : (int) woodo, ... ;
+- (void) in : (int) woodo, ... ;
+- (void) out : (int) woodo, ... ;
+- (void) inout : (int) woodo, ... ;
+- (void) bycopy : (int) woodo, ... ;
+- (void) byref : (int) woodo, ... ;
+- (void) oneway : (int) woodo, ... ;
+- (void) int : (int) woodo, ... ;
+- (void) char : (int) woodo, ... ;
+- (void) float : (int) woodo, ... ;
+- (void) double : (int) woodo, ... ;
+- (void) void : (int) woodo, ... ;
+- (void) _Bool : (int) woodo, ... ;
+@end
diff --git a/test/Parser/namelookup-bug-1.c b/test/Parser/namelookup-bug-1.c
new file mode 100644
index 000000000000..3c8b85a2d61a
--- /dev/null
+++ b/test/Parser/namelookup-bug-1.c
@@ -0,0 +1,7 @@
+// RUN: clang-cc -verify %s
+
+typedef int Object;
+
+struct Object *pp;
+
+Object staticObject1;
diff --git a/test/Parser/namelookup-bug-2.c b/test/Parser/namelookup-bug-2.c
new file mode 100644
index 000000000000..42298c39c46f
--- /dev/null
+++ b/test/Parser/namelookup-bug-2.c
@@ -0,0 +1,14 @@
+// RUN: clang-cc -verify %s
+
+typedef int Object;
+
+struct Object {int i1; } *P;
+
+void foo() {
+ struct Object { int i2; } *X;
+ Object:
+ {
+ Object a;
+ }
+}
+
diff --git a/test/Parser/objc-alias-printing.m b/test/Parser/objc-alias-printing.m
new file mode 100644
index 000000000000..e121bed0aea8
--- /dev/null
+++ b/test/Parser/objc-alias-printing.m
@@ -0,0 +1,18 @@
+// RUN: clang-cc -ast-print %s
+
+@protocol P1 @end
+@protocol P2 @end
+
+@interface INTF @end
+
+@compatibility_alias alias INTF;
+
+
+int foo ()
+{
+ INTF *pi;
+ INTF<P2,P1> *pi2;
+ alias *p;
+ alias<P1,P2> *p2;
+ return pi2 == p2;
+}
diff --git a/test/Parser/objc-category-neg-1.m b/test/Parser/objc-category-neg-1.m
new file mode 100644
index 000000000000..6c1bd2951736
--- /dev/null
+++ b/test/Parser/objc-category-neg-1.m
@@ -0,0 +1,8 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+void __assert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__));
+static __inline__ int __inline_isfinitef (float ) __attribute__ ((always_inline));
+
+@interface NSATSTypesetter (NSPantherCompatibility) // expected-error {{ "cannot find interface declaration for 'NSATSTypesetter'" }}
+- (id)lineFragmentRectForProposedRect:(id)proposedRect remainingRect:(id)remainingRect __attribute__((deprecated));
+@end
diff --git a/test/Parser/objc-forcollection-1.m b/test/Parser/objc-forcollection-1.m
new file mode 100644
index 000000000000..21ec308a28a1
--- /dev/null
+++ b/test/Parser/objc-forcollection-1.m
@@ -0,0 +1,43 @@
+// RUN: clang-cc -fsyntax-only %s
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+
+@protocol P @end
+
+@interface MyList
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+ int i;
+ for (id elem in self)
+ ++i;
+ for (MyList *elem in self)
+ ++i;
+ for (id<P> se in self)
+ ++i;
+
+ MyList<P> *p;
+ for (p in self)
+ ++i;
+
+ for (p in p)
+ ++i;
+}
+@end
+
diff --git a/test/Parser/objc-forcollection-neg-2.m b/test/Parser/objc-forcollection-neg-2.m
new file mode 100644
index 000000000000..ddb279b6f7c1
--- /dev/null
+++ b/test/Parser/objc-forcollection-neg-2.m
@@ -0,0 +1,38 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+
+@protocol P @end
+
+@interface MyList
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+ static i;// expected-warning {{type specifier missing, defaults to 'int'}}
+ for (id el, elem in self) // expected-error {{only one element declaration is allowed}}
+ ++i;
+ for (id el in self)
+ ++i;
+ MyList<P> ***p;
+ for (p in self) // expected-error {{selector element type 'MyList<P> ***' is not a valid object type}}
+ ++i;
+
+}
+@end
+
diff --git a/test/Parser/objc-forcollection-neg.m b/test/Parser/objc-forcollection-neg.m
new file mode 100644
index 000000000000..0f2bb90df85f
--- /dev/null
+++ b/test/Parser/objc-forcollection-neg.m
@@ -0,0 +1,37 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+
+@interface MyList
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+
+ int i=0;
+ for (int * elem in elem) // expected-error {{selector element type 'int *' is not a valid object}} \
+ expected-error {{collection expression type 'int *' is not a valid object}}
+ ++i;
+ for (i in elem) // expected-error {{use of undeclared identifier 'elem'}} \
+ expected-error {{selector element type 'int' is not a valid object}}
+ ++i;
+ for (id se in i) // expected-error {{collection expression type 'int' is not a valid object}}
+ ++i;
+}
+@end
+
diff --git a/test/Parser/objc-foreach-syntax.m b/test/Parser/objc-foreach-syntax.m
new file mode 100644
index 000000000000..977dccc88b1d
--- /dev/null
+++ b/test/Parser/objc-foreach-syntax.m
@@ -0,0 +1,26 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+
+
+@implementation MyList // expected-warning {{cannot find interface declaration for 'MyList'}}
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+
+int LOOP();
+
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+MyList * el;
+ for (el in @"foo")
+ { LOOP(); }
+}
+@end
+
+
+static int test7(id keys) {
+ for (id key; in keys) ; // expected-error {{use of undeclared identifier 'in'}}
+}
diff --git a/test/Parser/objc-init.m b/test/Parser/objc-init.m
new file mode 100644
index 000000000000..a91ac9cf285b
--- /dev/null
+++ b/test/Parser/objc-init.m
@@ -0,0 +1,41 @@
+// RUN: clang-cc -fsyntax-only -verify %s -pedantic
+// rdar://5707001
+
+@interface NSNumber;
+- () METH;
+- (unsigned) METH2;
+@end
+
+struct SomeStruct {
+ int x, y, z, q;
+};
+
+void test1() {
+ id objects[] = {[NSNumber METH]};
+}
+
+void test2(NSNumber x) { // expected-error {{Objective-C interface type 'NSNumber' cannot be passed by value}}
+ id objects[] = {[x METH]};
+}
+
+void test3(NSNumber *x) {
+ id objects[] = {[x METH]};
+}
+
+
+// rdar://5977581
+void test4() {
+ unsigned x[] = {[NSNumber METH2]+2};
+}
+
+void test5(NSNumber *x) {
+ unsigned y[] = {
+ [4][NSNumber METH2]+2, // expected-warning {{use of GNU 'missing =' extension in designator}}
+ [4][x METH2]+2 // expected-warning {{use of GNU 'missing =' extension in designator}}
+ };
+
+ struct SomeStruct z = {
+ .x = [x METH2], // ok.
+ .x [x METH2] // expected-error {{expected '=' or another designator}}
+ };
+}
diff --git a/test/Parser/objc-interfaces.m b/test/Parser/objc-interfaces.m
new file mode 100644
index 000000000000..7aa672901fff
--- /dev/null
+++ b/test/Parser/objc-interfaces.m
@@ -0,0 +1,8 @@
+// RUN: clang-cc %s -fsyntax-only -verify
+
+// Test features and error recovery for objc interfaces.
+
+@interface INTF
+- (int*) foo2 __attribute__((deprecated)) : (int) x1 __attribute__((deprecated)); // expected-error {{expected ';' after method prototype}}
+@end
+
diff --git a/test/Parser/objc-messaging-1.m b/test/Parser/objc-messaging-1.m
new file mode 100644
index 000000000000..4a36fc950fa8
--- /dev/null
+++ b/test/Parser/objc-messaging-1.m
@@ -0,0 +1,19 @@
+// RUN: clang-cc %s -parse-noop
+int main ()
+{
+ int i,j;
+ struct S *p;
+ id a, b, c;
+ [p ii];
+ [p if: 1 :2];
+ [p inout: 1 :2 another:(2,3,4)];
+ [p inout: 1 :2 another:(2,3,4), 6,6,8];
+ [p inout: 1 :2 another:(2,3,4), (6,4,5),6,8];
+ [p inout: 1 :2 another:(i+10), (i,j-1,5),6,8];
+ [p long: 1 :2 another:(i+10), (i,j-1,5),6,8];
+ [p : "Hello\n" :2 another:(i+10), (i,j-1,5),6,8];
+
+ // Comma expression as receiver (rdar://6222856)
+ [a, b, c foo];
+
+}
diff --git a/test/Parser/objc-messaging-neg-1.m b/test/Parser/objc-messaging-neg-1.m
new file mode 100644
index 000000000000..a1ec116fb7b4
--- /dev/null
+++ b/test/Parser/objc-messaging-neg-1.m
@@ -0,0 +1,7 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int main()
+ {
+ id a;
+ [a bla:0 6:7]; // expected-error {{expected ']'}}
+ }
diff --git a/test/Parser/objc-missing-impl.m b/test/Parser/objc-missing-impl.m
new file mode 100644
index 000000000000..9108451f1bff
--- /dev/null
+++ b/test/Parser/objc-missing-impl.m
@@ -0,0 +1,2 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+@end // expected-warning {{@end must appear in an @implementation context}}
diff --git a/test/Parser/objc-property-syntax.m b/test/Parser/objc-property-syntax.m
new file mode 100644
index 000000000000..cf75aaa2d5a2
--- /dev/null
+++ b/test/Parser/objc-property-syntax.m
@@ -0,0 +1,12 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+@interface MyClass {
+
+};
+@property unsigned char bufferedUTF8Bytes[4]; // expected-error {{property cannot have array or function type}}
+@property unsigned char bufferedUTFBytes:1; // expected-error {{property name cannot be a bitfield}}
+@end
+
+@implementation MyClass
+@end
+
diff --git a/test/Parser/objc-quirks.m b/test/Parser/objc-quirks.m
new file mode 100644
index 000000000000..2913b580c5fc
--- /dev/null
+++ b/test/Parser/objc-quirks.m
@@ -0,0 +1,10 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// FIXME: This is a horrible error message here. Fix.
+int @"s" = 5; // expected-error {{prefix attribute must be}}
+
+
+// rdar://6480479
+@interface A
+}; // expected-error {{missing @end}} expected-error {{expected external declaration}}
+
diff --git a/test/Parser/objc-try-catch-1.m b/test/Parser/objc-try-catch-1.m
new file mode 100644
index 000000000000..a8d37f0ab959
--- /dev/null
+++ b/test/Parser/objc-try-catch-1.m
@@ -0,0 +1,68 @@
+// RUN: clang-cc -fsyntax-only -verify %s &&
+// RUN: clang-cc -fsyntax-only -verify -x objective-c++ %s
+void * proc();
+
+@interface NSConstantString
+@end
+
+@interface Frob
+@end
+
+@interface Frob1
+@end
+
+void * foo()
+{
+ @try {
+ return proc();
+ }
+ @catch (Frob* ex) {
+ @throw;
+ }
+ @catch (Frob1* ex) {
+ @throw proc();
+ }
+ @finally {
+ @try {
+ return proc();
+ }
+ @catch (Frob* ex) {
+ @throw 1,2; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}}
+ }
+ @catch (float x) { // expected-error {{@catch parameter is not a pointer to an interface type}}
+
+ }
+ @catch(...) {
+ @throw (4,3,proc());
+ }
+ }
+
+ @try { // expected-error {{@try statement without a @catch and @finally clause}}
+ return proc();
+ }
+}
+
+
+void bar()
+{
+ @try {}// expected-error {{@try statement without a @catch and @finally clause}}
+ @"s"; // expected-warning {{result unused}}
+}
+
+void baz()
+{
+ @try {}// expected-error {{@try statement without a @catch and @finally clause}}
+ @try {}
+ @finally {}
+}
+
+void noTwoTokenLookAheadRequiresABitOfFancyFootworkInTheParser() {
+ @try {
+ // Do something
+ } @catch (...) {}
+ @try {
+ // Do something
+ } @catch (...) {}
+ return;
+}
+
diff --git a/test/Parser/objc-type-printing.m b/test/Parser/objc-type-printing.m
new file mode 100644
index 000000000000..d9ad70474f2b
--- /dev/null
+++ b/test/Parser/objc-type-printing.m
@@ -0,0 +1,19 @@
+// RUN: clang-cc -ast-print %s
+
+@protocol P1 @end
+@protocol P2 @end
+@protocol P3 @end
+
+@interface INTF
+- (INTF<P1>*) METH;
+@end
+
+void foo()
+{
+ INTF *pintf;
+ INTF<P1>* p1;
+ INTF<P1, P1>* p2;
+ INTF<P1, P3>* p3;
+ INTF<P1, P3, P2>* p4;
+ INTF<P2,P2, P3, P1>* p5;
+}
diff --git a/test/Parser/parmvardecl_conversion.c b/test/Parser/parmvardecl_conversion.c
new file mode 100644
index 000000000000..f35487ee95c6
--- /dev/null
+++ b/test/Parser/parmvardecl_conversion.c
@@ -0,0 +1,4 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+void f (int p[]) { p++; }
+
diff --git a/test/Parser/pointer-arithmetic.c b/test/Parser/pointer-arithmetic.c
new file mode 100644
index 000000000000..d252b42c9b15
--- /dev/null
+++ b/test/Parser/pointer-arithmetic.c
@@ -0,0 +1,9 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int *test1(int *a) { return a + 1; }
+int *test2(int *a) { return 1 + a; }
+int *test3(int *a) { return a - 1; }
+int test4(int *a, int *b) { return a - b; }
+
+int test5(int *a, int *b) { return a + b; } /* expected-error {{invalid operands}} */
+int *test6(int *a) { return 1 - a; } /* expected-error {{invalid operands}} */
diff --git a/test/Parser/pointer_promotion.c b/test/Parser/pointer_promotion.c
new file mode 100644
index 000000000000..0254828e0f02
--- /dev/null
+++ b/test/Parser/pointer_promotion.c
@@ -0,0 +1,18 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int test() {
+ void *vp;
+ int *ip;
+ char *cp;
+ struct foo *fp;
+ struct bar *bp;
+ short sint = 7;
+
+ if (ip < cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
+ if (cp < fp) {} // expected-warning {{comparison of distinct pointer types ('char *' and 'struct foo *')}}
+ if (fp < bp) {} // expected-warning {{comparison of distinct pointer types ('struct foo *' and 'struct bar *')}}
+ if (ip < 7) {} // expected-warning {{comparison between pointer and integer ('int *' and 'int')}}
+ if (sint < ip) {} // expected-warning {{comparison between pointer and integer ('int' and 'int *')}}
+ if (ip == cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
+}
+
diff --git a/test/Parser/pragma-pack.c b/test/Parser/pragma-pack.c
new file mode 100644
index 000000000000..d42bbe5c40d2
--- /dev/null
+++ b/test/Parser/pragma-pack.c
@@ -0,0 +1,32 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// Note that this puts the expected lines before the directives to work around
+// limitations in the -verify mode.
+
+/* expected-warning {{missing '(' after '#pragma pack'}}*/ #pragma pack 10
+#pragma pack()
+#pragma pack(8)
+
+/*expected-warning {{unknown action for '#pragma pack'}}*/ #pragma pack(hello)
+#pragma pack(push)
+#pragma pack(pop)
+
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(push,)
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(push,)
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(pop,)
+
+#pragma pack(push,i)
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(push,i,
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(push,i,)
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(push,i,help)
+
+#pragma pack(push,8)
+/* expected-warning {{missing ')' after '#pragma pack'}}*/ #pragma pack(push,8,
+/* expected-warning {{missing ')' after '#pragma pack'}}*/ #pragma pack(push,8,)
+/* expected-warning {{missing ')' after '#pragma pack'}}*/ #pragma pack(push,i,8
+#pragma pack(push,i,8)
+
+/* expected-warning {{missing ')' after '#pragma pack'}}*/ #pragma pack(push
+
+_Pragma("pack(push)")
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ _Pragma("pack(push,)")
diff --git a/test/Parser/prefix-attributes.m b/test/Parser/prefix-attributes.m
new file mode 100644
index 000000000000..bb6d04da2a08
--- /dev/null
+++ b/test/Parser/prefix-attributes.m
@@ -0,0 +1,8 @@
+// RUN: clang-cc -verify -fsyntax-only %s
+
+__attribute__((deprecated)) @class B; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+
+__attribute__((deprecated)) @interface A @end
+__attribute__((deprecated)) @protocol P0;
+__attribute__((deprecated)) @protocol P1
+@end
diff --git a/test/Parser/promote_types_in_proto.c b/test/Parser/promote_types_in_proto.c
new file mode 100644
index 000000000000..faff3e35d5a3
--- /dev/null
+++ b/test/Parser/promote_types_in_proto.c
@@ -0,0 +1,9 @@
+// RUN: clang-cc %s
+void functionPromotion(void f(char *const []));
+void arrayPromotion(char * const argv[]);
+
+int whatever(int argc, char *argv[])
+{
+ arrayPromotion(argv);
+ functionPromotion(arrayPromotion);
+}
diff --git a/test/Parser/recovery.c b/test/Parser/recovery.c
new file mode 100644
index 000000000000..89eac564a329
--- /dev/null
+++ b/test/Parser/recovery.c
@@ -0,0 +1,75 @@
+// RUN: clang-cc -fsyntax-only -verify -pedantic -fblocks %s
+
+// PR2241
+float test2241[2] = {
+ 1e, // expected-error {{exponent}}
+ 1ee0 // expected-error {{exponent}}
+};
+
+
+// Testcase derived from PR2692
+static char *f (char * (*g) (char **, int), char **p, ...) {
+ char *s;
+ va_list v; // expected-error {{identifier}}
+ s = g (p, __builtin_va_arg(v, int)); // expected-error {{identifier}}
+}
+
+
+// PR3172
+} // expected-error {{expected external declaration}}
+
+
+// rdar://6094870
+int test(int a) {
+ struct { int i; } x;
+
+ if (x.hello) // expected-error {{no member named 'hello'}}
+ test(0);
+ else
+ ;
+
+ if (x.hello == 0) // expected-error {{no member named 'hello'}}
+ test(0);
+ else
+ ;
+
+ if ((x.hello == 0)) // expected-error {{no member named 'hello'}}
+ test(0);
+ else
+ ;
+
+ if (x.i == 0)) // expected-error {{expected expression}}
+ test(0);
+ else
+ ;
+}
+
+
+
+char (((( /* expected-note {{to match this '('}} */
+ *X x ] )))); /* expected-error {{expected ')'}} */
+
+; // expected-warning {{ISO C does not allow an extra ';' outside of a function}}
+
+
+
+
+struct S { void *X, *Y; };
+
+struct S A = {
+&BADIDENT, 0 /* expected-error {{use of undeclared identifier}} */
+};
+
+// rdar://6248081
+int test6248081() {
+ [10] // expected-error {{expected expression}}
+}
+
+struct forward; // expected-note{{forward declaration of 'struct forward'}}
+void x(struct forward* x) {switch(x->a) {}} // expected-error {{incomplete definition of type}}
+
+// PR3410
+void foo() {
+ int X;
+ X = 4 // expected-error{{expected ';' after expression}}
+}
diff --git a/test/Parser/selector-1.m b/test/Parser/selector-1.m
new file mode 100644
index 000000000000..85ef919689df
--- /dev/null
+++ b/test/Parser/selector-1.m
@@ -0,0 +1,14 @@
+// RUN: clang-cc -parse-noop %s
+
+int main() {
+ SEL s = @selector(retain);
+ SEL s1 = @selector(meth1:);
+ SEL s2 = @selector(retainArgument::);
+ SEL s3 = @selector(retainArgument:::::);
+ SEL s4 = @selector(retainArgument:with:);
+ SEL s5 = @selector(meth1:with:with:);
+ SEL s6 = @selector(getEnum:enum:bool:);
+ SEL s7 = @selector(char:float:double:unsigned:short:long:);
+
+ SEL s9 = @selector(:enum:bool:);
+}
diff --git a/test/Parser/statements.c b/test/Parser/statements.c
new file mode 100644
index 000000000000..c5923bc0641b
--- /dev/null
+++ b/test/Parser/statements.c
@@ -0,0 +1,56 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+int test1() {
+ { ; { ;;}} ;;
+}
+
+int test2() {
+ if (0) { if (1) {} } else { }
+
+ do { } while (0);
+
+ while (0) while(0) do ; while(0);
+
+ for (0;0;0)
+ for (;;)
+ for (9;0;2)
+ ;
+ for (int X = 0; 0; 0);
+}
+
+int test3() {
+ switch (0) {
+
+ case 4:
+ if (0) {
+ case 6: ;
+ }
+ default:
+ ;
+ }
+}
+
+int test4() {
+ if (0); // expected-warning {{if statement has empty body}}
+
+ int X; // declaration in a block.
+
+foo: if (0); // expected-warning {{if statement has empty body}}
+}
+
+typedef int t;
+void test5() {
+ if (0); // expected-warning {{if statement has empty body}}
+
+ t x = 0;
+
+ if (0); // expected-warning {{if statement has empty body}}
+}
+
+
+void test6(void) {
+ do
+ . // expected-error {{expected expression}}
+ while (0);
+}
+
diff --git a/test/Parser/struct-recursion.c b/test/Parser/struct-recursion.c
new file mode 100644
index 000000000000..11e5f7e97ab1
--- /dev/null
+++ b/test/Parser/struct-recursion.c
@@ -0,0 +1,11 @@
+// RUN: clang-cc %s -fsyntax-only
+
+// C99 6.7.2.3p11
+
+// mutually recursive structs
+struct s1 { struct s2 *A; };
+struct s2 { struct s1 *B; };
+
+// both types are complete now.
+struct s1 a;
+struct s2 b;
diff --git a/test/Parser/traditional_arg_scope.c b/test/Parser/traditional_arg_scope.c
new file mode 100644
index 000000000000..2a21ec3708d4
--- /dev/null
+++ b/test/Parser/traditional_arg_scope.c
@@ -0,0 +1,7 @@
+// RUN: clang-cc -fsyntax-only %s -verify
+
+int x(a) int a; {return a;}
+int y(b) int b; {return a;} // expected-error {{use of undeclared identifier}}
+
+// PR2332
+int a(a)int a;{a=10;return a;}
diff --git a/test/Parser/typeof.c b/test/Parser/typeof.c
new file mode 100644
index 000000000000..a7c488023ae2
--- /dev/null
+++ b/test/Parser/typeof.c
@@ -0,0 +1,19 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+typedef int TInt;
+
+static void test() {
+ int *pi;
+
+ int typeof (int) aIntInt; // expected-error{{cannot combine with previous 'int' declaration specifier}}
+ short typeof (int) aShortInt; // expected-error{{'short typeof' is invalid}}
+ int int ttt; // expected-error{{cannot combine with previous 'int' declaration specifier}}
+ typeof(TInt) anInt;
+ short TInt eee; // expected-error{{expected ';' at end of declaration}}
+ void ary[7] fff; // expected-error{{array has incomplete element type 'void'}} expected-error{{expected ';' at end of declaration}}
+ typeof(void ary[7]) anIntError; // expected-error{{expected ')'}} expected-note {{to match this '('}} expected-error {{variable has incomplete type 'typeof(void)' (aka 'void')}}
+ typeof(const int) aci;
+ const typeof (*pi) aConstInt;
+ int xx;
+ int *i;
+}
diff --git a/test/Parser/types.c b/test/Parser/types.c
new file mode 100644
index 000000000000..2131ab0346f4
--- /dev/null
+++ b/test/Parser/types.c
@@ -0,0 +1,14 @@
+// RUN: clang-cc %s -parse-noop
+
+// Test the X can be overloaded inside the struct.
+typedef int X;
+struct Y { short X; };
+
+// Variable shadows type, PR3872
+
+typedef struct foo { int x; } foo;
+void test() {
+ foo *foo;
+ foo->x = 0;
+}
+