diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
| commit | bca07a4524feb4edec581062d631a13116320a24 (patch) | |
| tree | a9243275843fbeaa590afc07ee888e006b8d54ea /test/Parser | |
| parent | 998bc5802ecdd65ce3b270f6c69a8ae8557f0a10 (diff) | |
Notes
Diffstat (limited to 'test/Parser')
36 files changed, 427 insertions, 46 deletions
diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c index ec272cdf9c80..9df8fa3a4e91 100644 --- a/test/Parser/MicrosoftExtensions.c +++ b/test/Parser/MicrosoftExtensions.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -Wno-missing-declarations -x objective-c++ %s +// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -Wno-missing-declarations -x objective-c++ %s __stdcall int func0(); int __stdcall func(); typedef int (__cdecl *tptr)(); @@ -21,6 +21,7 @@ void __forceinline InterlockedBitTestAndSet (long *Base, long Bit) setc al }; } +_inline int foo99() { return 99; } void *_alloca(int); @@ -30,9 +31,34 @@ void foo() { typedef bool (__stdcall __stdcall *blarg)(int); +void local_callconv() +{ + bool (__stdcall *p)(int); +} // Charify extension. #define FOO(x) #@x char x = FOO(a); typedef enum E { e1 }; + + +
+ + + +/* Microsoft attribute tests */ +[repeatable][source_annotation_attribute( Parameter|ReturnValue )] +struct SA_Post{ SA_Post(); int attr; }; + +[returnvalue:SA_Post( attr=1)] +int foo1([SA_Post(attr=1)] void *param); + + + +void ms_intrinsics(int a) +{ + __noop(); + __assume(a); + +} diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp new file mode 100644 index 000000000000..fd0d7d50d0eb --- /dev/null +++ b/test/Parser/MicrosoftExtensions.cpp @@ -0,0 +1,113 @@ +// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions + +/* Microsoft attribute tests */ +[repeatable][source_annotation_attribute( Parameter|ReturnValue )] +struct SA_Post{ SA_Post(); int attr; }; + +[returnvalue:SA_Post( attr=1)] +int foo1([SA_Post(attr=1)] void *param); + +namespace { + [returnvalue:SA_Post(attr=1)] + int foo2([SA_Post(attr=1)] void *param); +} + +class T { + [returnvalue:SA_Post(attr=1)] + int foo3([SA_Post(attr=1)] void *param); +}; + +extern "C" { + [returnvalue:SA_Post(attr=1)] + int foo5([SA_Post(attr=1)] void *param); +} + +class class_attr { +public: + class_attr([SA_Pre(Null=SA_No,NullTerminated=SA_Yes)] int a) + { + } +}; + + + +void uuidof_test1() +{ + __uuidof(0); // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}} +} + +typedef struct _GUID +{ + unsigned long Data1; + unsigned short Data2; + unsigned short Data3; + unsigned char Data4[8]; +} GUID; + +struct __declspec(uuid(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}} +struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}} +struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 { };// expected-error {{uuid attribute contains a malformed GUID}} +struct __declspec(uuid("0000000-0000-0000-Z234-000000000047")) uuid_attr_bad4 { };// expected-error {{uuid attribute contains a malformed GUID}} +struct __declspec(uuid("000000000000-0000-1234-000000000047")) uuid_attr_bad5 { };// expected-error {{uuid attribute contains a malformed GUID}} + + + +struct __declspec(uuid("000000A0-0000-0000-C000-000000000046")) +struct_with_uuid { }; +struct struct_without_uuid { }; + +struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) +struct_with_uuid2; + +struct +struct_with_uuid2 {} ; + +int uuid_sema_test() +{ + struct_with_uuid var_with_uuid[1]; + struct_without_uuid var_without_uuid[1]; + + __uuidof(struct_with_uuid); + __uuidof(struct_with_uuid2); + __uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}} + __uuidof(struct_with_uuid*); + __uuidof(struct_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}} + + __uuidof(var_with_uuid); + __uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}} + __uuidof(var_with_uuid[1]); + __uuidof(var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}} + __uuidof(&var_with_uuid[1]); + __uuidof(&var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}} + + __uuidof(0); + __uuidof(1);// expected-error {{cannot call operator __uuidof on a type with no GUID}} +} + + +template <class T> +void template_uuid() +{ + T expr; + + __uuidof(T); + __uuidof(expr); +} + + + +class CtorCall { +public: + CtorCall& operator=(const CtorCall& that); + + int a; +}; + +CtorCall& CtorCall::operator=(const CtorCall& that) +{ + if (this != &that) { + this->CtorCall::~CtorCall(); + this->CtorCall::CtorCall(that); // expected-warning {{explicit constructor calls are a Microsoft extension}} + } + return *this; +} diff --git a/test/Parser/altivec.c b/test/Parser/altivec.c index 92ec688bc01d..64f82f7a563c 100644 --- a/test/Parser/altivec.c +++ b/test/Parser/altivec.c @@ -100,6 +100,16 @@ void f() { __vector unsigned int tv = gccv; gccv = v; gccvector unsigned int tgv = v; + + int res_i; + // bug 7553 - Problem with '==' and vectors + res_i = (vv_sc == vv_sc); + res_i = (vv_uc != vv_uc); + res_i = (vv_s > vv_s); + res_i = (vv_us >= vv_us); + res_i = (vv_i < vv_i); + res_i = (vv_ui <= vv_ui); + res_i = (vv_f <= vv_f); } // bug 6895 - Vectorl literal casting confusion. diff --git a/test/Parser/asm-constraints-pr7869.c b/test/Parser/asm-constraints-pr7869.c index d6f1725f1a84..db369911cf8c 100644 --- a/test/Parser/asm-constraints-pr7869.c +++ b/test/Parser/asm-constraints-pr7869.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 %s int a, b, c, d, e, f, g, h, i, j, k, l; diff --git a/test/Parser/cuda-kernel-call.cu b/test/Parser/cuda-kernel-call.cu new file mode 100644 index 000000000000..f95ae9e6195f --- /dev/null +++ b/test/Parser/cuda-kernel-call.cu @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void foo(void) { + foo<<<1; // expected-error {{expected '>>>'}} expected-note {{to match this '<<<'}} + + foo<<<1,1>>>; // expected-error {{expected '('}} + + foo<<<>>>(); // expected-error {{expected expression}} +} diff --git a/test/Parser/cxx-altivec.cpp b/test/Parser/cxx-altivec.cpp index 8f463308112b..4d924503bbb9 100644 --- a/test/Parser/cxx-altivec.cpp +++ b/test/Parser/cxx-altivec.cpp @@ -127,27 +127,17 @@ vector int v4 = (vector int)(1, 2, 3, 4); vector float v5 = (vector float)(1.0f, 2.0f, 3.0f, 4.0f); vector char v6 = (vector char)((vector int)(1+2, -2, (int)(2.0 * 3), -(5-3))); -#if 0 // Not ready yet. // bug 7553 - Problem with '==' and vectors void func() { - vector int v10i = (vector int)(1, 2, 3, 4); - vector int v11i = (vector int)(1, 2, 3, 4); - bool r10ieq = (v10i == v11i); - bool r10ine = (v10i != v11i); - bool r10igt = (v10i > v11i); - bool r10ige = (v10i >= v11i); - bool r10ilt = (v10i < v11i); - bool r10ile = (v10i <= v11i); - vector float v10f = (vector float)(1.0f, 2.0f, 3.0f, 4.0f); - vector float v11f = (vector float)(1.0f, 2.0f, 3.0f, 4.0f); - bool r10feq = (v10f == v11f); - bool r10fne = (v10f != v11f); - bool r10fgt = (v10f > v11f); - bool r10fge = (v10f >= v11f); - bool r10flt = (v10f < v11f); - bool r10fle = (v10f <= v11f); + bool res_b; + res_b = (vv_sc == vv_sc); + res_b = (vv_uc != vv_uc); + res_b = (vv_s > vv_s); + res_b = (vv_us >= vv_us); + res_b = (vv_i < vv_i); + res_b = (vv_ui <= vv_ui); + res_b = (vv_f <= vv_f); } -#endif // vecreturn attribute test struct Vector @@ -161,3 +151,20 @@ Vector Add(Vector lhs, Vector rhs) result.xyzw = vec_add(lhs.xyzw, rhs.xyzw); return result; // This will (eventually) be returned in a register } + +// vecreturn attribute test - should error because of virtual function. +class VectorClassNonPod +{ + __vector float xyzw; +public: + VectorClassNonPod() {} + virtual ~VectorClassNonPod() {} +} __attribute__((vecreturn)); // expected-error {{the vecreturn attribute can only be used on a POD (plain old data) class or structure (i.e. no virtual functions)}} + +// vecreturn attribute test - should error because of virtual function. +class VectorClassMultipleMembers +{ +public: + __vector float xyzw; + __vector float abcd; +} __attribute__((vecreturn)); // expected-error {{the vecreturn attribute can only be used on a class or structure with one member, which must be a vector}} diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp index 57831a463b9b..f863bd198e50 100644 --- a/test/Parser/cxx-class.cpp +++ b/test/Parser/cxx-class.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s class C; class C { public: @@ -14,7 +14,11 @@ protected: public: void m() { int l = 2; - } + }; + + template<typename T> void mt(T) { }; + ; // expected-warning{{extra ';' inside a class}} + virtual int vf() const volatile = 0; private: diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index e00ffd070fd8..6d720d36a259 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -6,6 +6,9 @@ struct Type { int Type; }; +// rdar://8365458 +typedef char bool; // expected-error {{redeclaration of C++ built-in type 'bool'}} \ + // expected-warning {{declaration does not declare anything}} // PR4451 - We should recover well from the typo of '::' as ':' in a2. namespace y { @@ -83,3 +86,14 @@ struct CodeCompleteConsumer { void CodeCompleteConsumer::() { // expected-error {{xpected unqualified-id}} } + +; + +// PR8380 +extern "" // expected-error {{unknown linkage language}} +test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \ + // expected-error {{expected ';' after top level declarator}} + + int test6b; + + diff --git a/test/Parser/cxx-in-c.c b/test/Parser/cxx-in-c.c new file mode 100644 index 000000000000..f5fa39bd0cb9 --- /dev/null +++ b/test/Parser/cxx-in-c.c @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// PR9137 +void f0(int x) : {}; // expected-error{{expected function body after function declarator}} +void f1(int x) try {}; // expected-error{{expected function body after function declarator}} diff --git a/test/Parser/cxx-reference.cpp b/test/Parser/cxx-reference.cpp index 46f9fb07dba0..fae938bcaab0 100644 --- a/test/Parser/cxx-reference.cpp +++ b/test/Parser/cxx-reference.cpp @@ -18,4 +18,4 @@ int & volatile Y = val; // expected-error {{'volatile' qualifier may not be appl 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}} +typedef int && RV; // expected-warning {{rvalue references are a C++0x extension}} diff --git a/test/Parser/cxx-stmt.cpp b/test/Parser/cxx-stmt.cpp index fdd573e6bfa5..795aca6e93c0 100644 --- a/test/Parser/cxx-stmt.cpp +++ b/test/Parser/cxx-stmt.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s void f1() { diff --git a/test/Parser/cxx-template-argument.cpp b/test/Parser/cxx-template-argument.cpp index 532b4c9894b7..c85b1c928111 100644 --- a/test/Parser/cxx-template-argument.cpp +++ b/test/Parser/cxx-template-argument.cpp @@ -7,3 +7,6 @@ template<typename T> struct A {}; A<int+> int x; // expected-error {{expected '>'}} expected-error {{expected unqualified-id}} A<int x; // expected-error {{expected '>'}} +// PR8912 +template <bool> struct S {}; +S<bool(2 > 1)> s; diff --git a/test/Parser/cxx-template-decl.cpp b/test/Parser/cxx-template-decl.cpp index 3a97efac19ed..4717dbb7dc2d 100644 --- a/test/Parser/cxx-template-decl.cpp +++ b/test/Parser/cxx-template-decl.cpp @@ -6,7 +6,9 @@ template x; // expected-error {{C++ requires a type specifier for al // expected-error {{does not refer}} export template x; // expected-error {{expected '<' after 'template'}} export template<class T> class x0; // expected-warning {{exported templates are unsupported}} -template < ; // expected-error {{parse error}} expected-warning {{declaration does not declare anything}} +template < ; // expected-error {{parse error}} \ +// expected-error{{expected ',' or '>' in template-parameter-list}} \ +// expected-warning {{declaration does not declare anything}} template <template X> struct Err1; // expected-error {{expected '<' after 'template'}} \ // expected-error{{extraneous}} template <template <typename> > struct Err2; // expected-error {{expected 'class' before '>'}} \ diff --git a/test/Parser/cxx-throw.cpp b/test/Parser/cxx-throw.cpp index a87881647dd4..20b8f4b754ab 100644 --- a/test/Parser/cxx-throw.cpp +++ b/test/Parser/cxx-throw.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s int i; diff --git a/test/Parser/cxx0x-attributes.cpp b/test/Parser/cxx0x-attributes.cpp index 67b2ea6f62ea..3147de940418 100644 --- a/test/Parser/cxx0x-attributes.cpp +++ b/test/Parser/cxx0x-attributes.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s +// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify -std=c++0x %s // Declaration syntax checks [[]] int before_attr; @@ -29,7 +29,6 @@ extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}} [[]] using namespace ns; // Argument tests -[[final()]] int final_params; // expected-error {{C++0x attribute 'final' cannot have an argument list}} [[align]] int aligned_no_params; // expected-error {{C++0x attribute 'align' must have an argument list}} [[align(i)]] int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} diff --git a/test/Parser/cxx0x-in-cxx98.cpp b/test/Parser/cxx0x-in-cxx98.cpp new file mode 100644 index 000000000000..e0cbc23f5811 --- /dev/null +++ b/test/Parser/cxx0x-in-cxx98.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s + +inline namespace N { // expected-warning{{inline namespaces are a C++0x feature}} +struct X { + template<typename ...Args> // expected-warning{{variadic templates are a C++0x extension}} + void f(Args &&...) &; // expected-warning{{rvalue references are a C++0x extension}} \ + // expected-warning{{reference qualifiers on functions are a C++0x extension}} +}; +} + diff --git a/test/Parser/cxx0x-override-control-keywords.cpp b/test/Parser/cxx0x-override-control-keywords.cpp new file mode 100644 index 000000000000..f959f7a9952c --- /dev/null +++ b/test/Parser/cxx0x-override-control-keywords.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +struct Base { + virtual void override(); +}; + +struct S : Base { + virtual void final() final; + virtual void override() override; + virtual void n() new; + int i : 3 new; + int j new; +}; + +struct T { + // virt-specifier-seq is only valid in member-declarators, and a function definition is not a member-declarator. + // FIXME: This currently doesn't work. + // virtual void f() const override { } +}; + +struct override; +struct Base2 { + virtual override override(int override); +}; + +struct A : Base2 { + virtual struct override override(int override) override; +}; diff --git a/test/Parser/encode.m b/test/Parser/encode.m index e0e753508119..7b8022e78dc0 100644 --- a/test/Parser/encode.m +++ b/test/Parser/encode.m @@ -1,8 +1,8 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s int main(void) { - const char ch = @encode(char *)[2]; - char c = @encode(char *)[2] + 4; + const char ch = @encode(char *)[0]; + char c = @encode(char *)[0] + 4; return c; } diff --git a/test/Parser/expressions.c b/test/Parser/expressions.c index ffc5c83a0a73..6015e918a340 100644 --- a/test/Parser/expressions.c +++ b/test/Parser/expressions.c @@ -39,7 +39,8 @@ void test_sizeof(){ // PR3418 int test_leading_extension() { - __extension__ (*(char*)0) = 1; + __extension__ (*(char*)0) = 1; // expected-warning {{indirection of non-volatile null pointer}} \ + // expected-note {{consider using __builtin_trap}} return 0; } diff --git a/test/Parser/for.cpp b/test/Parser/for.cpp new file mode 100644 index 000000000000..e41383938934 --- /dev/null +++ b/test/Parser/for.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void f1() { + int n; + + for (n = 0; n < 10; n++); + + for (n = 0 n < 10; n++); // expected-error {{expected ';' in 'for'}} + for (n = 0; n < 10 n++); // expected-error {{expected ';' in 'for'}} + + for (int n = 0 n < 10; n++); // expected-error {{expected ';' in 'for'}} + for (int n = 0; n < 10 n++); // expected-error {{expected ';' in 'for'}} + + for (n = 0 bool b = n < 10; n++); // expected-error {{expected ';' in 'for'}} + for (n = 0; bool b = n < 10 n++); // expected-error {{expected ';' in 'for'}} + + for (n = 0 n < 10 n++); // expected-error 2{{expected ';' in 'for'}} + + for (;); // expected-error {{expected ';' in 'for'}} +} diff --git a/test/Parser/goto-ident.c b/test/Parser/goto-ident.c deleted file mode 100644 index 32051dc677ec..000000000000 --- a/test/Parser/goto-ident.c +++ /dev/null @@ -1,6 +0,0 @@ -/* RUN: %clang_cc1 -fsyntax-only -verify %s -*/ - -void foo() { - goto ; /* expected-error {{expected identifier}} */ -} diff --git a/test/Parser/goto.c b/test/Parser/goto.c new file mode 100644 index 000000000000..a3e01174eb94 --- /dev/null +++ b/test/Parser/goto.c @@ -0,0 +1,30 @@ +/* RUN: %clang_cc1 -fsyntax-only -verify %s +*/ + +void test1() { + goto ; /* expected-error {{expected identifier}} */ +} + + +void test2() { + l: /* expected-note {{previous definition is here}} */ + + { + __label__ l; + l: goto l; + } + + { + __label__ l; + __label__ h; /* expected-error {{use of undeclared label 'h'}} */ + l: goto l; + } + + /* PR3429 & rdar://8287027 + */ + { + l: /* expected-error {{redefinition of label 'l'}} */ + ; + } + +} diff --git a/test/Parser/missing-end-2.m b/test/Parser/missing-end-2.m new file mode 100644 index 000000000000..63dc96558361 --- /dev/null +++ b/test/Parser/missing-end-2.m @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// rdar: //7824372 + +@interface A +-(void) im0; + +@implementation A // expected-error {{missing @end}} +@end + +@interface B { +} + +@implementation B // expected-error {{missing @end}} +@end + +@interface C +@property int P; + +@implementation C // expected-error 2 {{missing @end}} diff --git a/test/Parser/missing-end-3.m b/test/Parser/missing-end-3.m new file mode 100644 index 000000000000..3b226376dc58 --- /dev/null +++ b/test/Parser/missing-end-3.m @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// rdar://8283484 +@interface blah { + @private +} +// since I forgot the @end here it should say something + +@interface blah // expected-error {{missing @end}} +@end // and Unknown type name 'end' here + diff --git a/test/Parser/objc-forcollection-neg-2.m b/test/Parser/objc-forcollection-neg-2.m index e02c51c1ba35..6aa74c9c0b45 100644 --- a/test/Parser/objc-forcollection-neg-2.m +++ b/test/Parser/objc-forcollection-neg-2.m @@ -1,11 +1,11 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s typedef struct objc_class *Class; +struct __objcFastEnumerationState; typedef struct objc_object { Class isa; } *id; - @protocol P @end @interface MyList diff --git a/test/Parser/objc-forcollection-neg.m b/test/Parser/objc-forcollection-neg.m index 0ba093efa08a..d896c35f3f69 100644 --- a/test/Parser/objc-forcollection-neg.m +++ b/test/Parser/objc-forcollection-neg.m @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +struct __objcFastEnumerationState; typedef struct objc_class *Class; typedef struct objc_object { Class isa; diff --git a/test/Parser/objc-foreach-syntax.m b/test/Parser/objc-foreach-syntax.m index 943540ef1f23..cc82725b17d7 100644 --- a/test/Parser/objc-foreach-syntax.m +++ b/test/Parser/objc-foreach-syntax.m @@ -1,7 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s - - +struct __objcFastEnumerationState; @implementation MyList // expected-warning {{cannot find interface declaration for 'MyList'}} - (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount { diff --git a/test/Parser/objc-interfaces.m b/test/Parser/objc-interfaces.m index aac3faa4350a..0ae17f15ee4d 100644 --- a/test/Parser/objc-interfaces.m +++ b/test/Parser/objc-interfaces.m @@ -3,6 +3,6 @@ // Test features and error recovery for objc interfaces. @interface INTF -- (int*) foo2 __attribute__((deprecated)) : (int) x1 __attribute__((deprecated)); // expected-error {{expected ';' after method prototype}} +- (int*) foo2 __attribute__((deprecated)) : (int) x1 __attribute__((deprecated)); // expected-error {{expected ';' after method prototype}} expected-error {{method type specifier must start with '-' or '+'}} @end diff --git a/test/Parser/objc-property-syntax.m b/test/Parser/objc-property-syntax.m index 064a2090b005..6ef2ad7c527d 100644 --- a/test/Parser/objc-property-syntax.m +++ b/test/Parser/objc-property-syntax.m @@ -1,14 +1,17 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s @interface MyClass { - + int prop; }; @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}} @property(nonatomic, retain, setter=ab_setDefaultToolbarItems) MyClass *ab_defaultToolbarItems; // expected-error {{method name referenced in property setter attribute must end with ':'}} + +@property int prop; @end @implementation MyClass -@dynamic ab_defaultToolbarItems; +@dynamic ab_defaultToolbarItems // expected-error{{expected ';' after @dynamic}} +@synthesize prop // expected-error{{expected ';' after @synthesize}} @end diff --git a/test/Parser/objc-quirks.m b/test/Parser/objc-quirks.m index b6671d1cf947..591bca222a93 100644 --- a/test/Parser/objc-quirks.m +++ b/test/Parser/objc-quirks.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s // FIXME: This is a horrible error message here. Fix. int @"s" = 5; // expected-error {{prefix attribute must be}} @@ -6,7 +6,9 @@ int @"s" = 5; // expected-error {{prefix attribute must be}} // rdar://6480479 @interface A -}; // expected-error {{missing @end}} expected-error {{expected external declaration}} +}; // expected-error {{missing @end}} \ +// expected-error {{expected external declaration}} \ +// expected-warning{{extra ';' outside of a function}} @@ -26,3 +28,5 @@ int @"s" = 5; // expected-error {{prefix attribute must be}} [(super) a]; // expected-error {{use of undeclared identifier 'super'}} } @end + +@compatibility_alias A3 A2; diff --git a/test/Parser/opencl-kernel.cl b/test/Parser/opencl-kernel.cl new file mode 100644 index 000000000000..3abb62b6169c --- /dev/null +++ b/test/Parser/opencl-kernel.cl @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +__kernel void test() +{ +} + +kernel void test1() +{ +} diff --git a/test/Parser/opencl-pragma.cl b/test/Parser/opencl-pragma.cl new file mode 100644 index 000000000000..5b6c55ab0743 --- /dev/null +++ b/test/Parser/opencl-pragma.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +#pragma OPENCL EXTENSION cl_no_such_extension : disable /* expected-warning {{unknown OpenCL extension 'cl_no_such_extension' - ignoring}} */ + +#pragma OPENCL EXTENSION cl_khr_fp64 : on /* expected-warning {{expected 'enable' or 'disable' - ignoring}} */ + +#pragma OPENCL FP_CONTRACT ON +#pragma OPENCL FP_CONTRACT OFF +#pragma OPENCL FP_CONTRACT DEFAULT +#pragma OPENCL FP_CONTRACT FOO // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}} diff --git a/test/Parser/opencl-storage-class.cl b/test/Parser/opencl-storage-class.cl new file mode 100644 index 000000000000..d479358f0024 --- /dev/null +++ b/test/Parser/opencl-storage-class.cl @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only + +void test_storage_class_specs() +{ + static int a; // expected-error {{OpenCL does not support the 'static' storage class specifier}} + register int b; // expected-error {{OpenCL does not support the 'register' storage class specifier}} + extern int c; // expected-error {{OpenCL does not support the 'extern' storage class specifier}} + auto int d; // expected-error {{OpenCL does not support the 'auto' storage class specifier}} +} diff --git a/test/Parser/placeholder-recovery.m b/test/Parser/placeholder-recovery.m new file mode 100644 index 000000000000..1fc154955d50 --- /dev/null +++ b/test/Parser/placeholder-recovery.m @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// FIXME: We could do much better with this, if we recognized +// placeholders somehow. However, we're content with not generating +// bogus 'archaic' warnings with bad location info. +@protocol <#protocol name#> <NSObject> // expected-error 2{{expected identifier}} \ +// expected-error{{cannot find protocol declaration for 'NSObject'}} \ +// expected-warning{{protocol qualifiers without 'id'}} + +<#methods#> // expected-error{{expected identifier}} + +@end // expected-error{{prefix attribute}} diff --git a/test/Parser/recovery.c b/test/Parser/recovery.c index 6cd95da878d2..1b33f0225bce 100644 --- a/test/Parser/recovery.c +++ b/test/Parser/recovery.c @@ -78,3 +78,9 @@ void foo() { // rdar://7980651 typedef int intptr_t; // expected-note {{'intptr_t' declared here}} void bar(intptr y); // expected-error {{unknown type name 'intptr'; did you mean 'intptr_t'?}} + +void test1(void) { + int x = 2: // expected-error {{expected ';' at end of declaration}} + int y = x; + int z = y; +} diff --git a/test/Parser/switch-recovery.cpp b/test/Parser/switch-recovery.cpp index 8eb4cff4fbe1..f11babc5b600 100644 --- a/test/Parser/switch-recovery.cpp +++ b/test/Parser/switch-recovery.cpp @@ -3,10 +3,32 @@ // <rdar://problem/7971948> struct A {}; struct B { - void foo() { + void foo(int b) { switch (a) { // expected-error{{use of undeclared identifier 'a'}} default: return; } + + switch (b) { + case 17 // expected-error{{expected ':' after 'case'}} + break; + + default // expected-error{{expected ':' after 'default'}} + return; + } + } + + void test2() { + enum X { Xa, Xb } x; + + switch (x) { // expected-warning {{enumeration value 'Xb' not handled in switch}} + case Xa; // expected-error {{expected ':' after 'case'}} + break; + } + + switch (x) { + default; // expected-error {{expected ':' after 'default'}} + break; + } } }; |
