From bca07a4524feb4edec581062d631a13116320a24 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 20 Feb 2011 13:06:31 +0000 Subject: Vendor import of clang trunk r126079: http://llvm.org/svn/llvm-project/cfe/trunk@126079 --- test/Parser/MicrosoftExtensions.c | 28 +++++- test/Parser/MicrosoftExtensions.cpp | 113 ++++++++++++++++++++++++ test/Parser/altivec.c | 10 +++ test/Parser/asm-constraints-pr7869.c | 2 +- test/Parser/cuda-kernel-call.cu | 9 ++ test/Parser/cxx-altivec.cpp | 43 +++++---- test/Parser/cxx-class.cpp | 8 +- test/Parser/cxx-decl.cpp | 14 +++ test/Parser/cxx-in-c.c | 5 ++ test/Parser/cxx-reference.cpp | 2 +- test/Parser/cxx-stmt.cpp | 2 +- test/Parser/cxx-template-argument.cpp | 3 + test/Parser/cxx-template-decl.cpp | 4 +- test/Parser/cxx-throw.cpp | 2 +- test/Parser/cxx0x-attributes.cpp | 3 +- test/Parser/cxx0x-in-cxx98.cpp | 10 +++ test/Parser/cxx0x-override-control-keywords.cpp | 28 ++++++ test/Parser/encode.m | 4 +- test/Parser/expressions.c | 3 +- test/Parser/for.cpp | 20 +++++ test/Parser/goto-ident.c | 6 -- test/Parser/goto.c | 30 +++++++ test/Parser/missing-end-2.m | 19 ++++ test/Parser/missing-end-3.m | 10 +++ test/Parser/objc-forcollection-neg-2.m | 2 +- test/Parser/objc-forcollection-neg.m | 1 + test/Parser/objc-foreach-syntax.m | 3 +- test/Parser/objc-interfaces.m | 2 +- test/Parser/objc-property-syntax.m | 7 +- test/Parser/objc-quirks.m | 8 +- test/Parser/opencl-kernel.cl | 9 ++ test/Parser/opencl-pragma.cl | 12 +++ test/Parser/opencl-storage-class.cl | 9 ++ test/Parser/placeholder-recovery.m | 12 +++ test/Parser/recovery.c | 6 ++ test/Parser/switch-recovery.cpp | 24 ++++- 36 files changed, 427 insertions(+), 46 deletions(-) create mode 100644 test/Parser/MicrosoftExtensions.cpp create mode 100644 test/Parser/cuda-kernel-call.cu create mode 100644 test/Parser/cxx-in-c.c create mode 100644 test/Parser/cxx0x-in-cxx98.cpp create mode 100644 test/Parser/cxx0x-override-control-keywords.cpp create mode 100644 test/Parser/for.cpp delete mode 100644 test/Parser/goto-ident.c create mode 100644 test/Parser/goto.c create mode 100644 test/Parser/missing-end-2.m create mode 100644 test/Parser/missing-end-3.m create mode 100644 test/Parser/opencl-kernel.cl create mode 100644 test/Parser/opencl-pragma.cl create mode 100644 test/Parser/opencl-storage-class.cl create mode 100644 test/Parser/placeholder-recovery.m (limited to 'test/Parser') 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 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 +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 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 struct A {}; A int x; // expected-error {{expected '>'}} expected-error {{expected unqualified-id}} A'}} +// PR8912 +template struct S {}; +S 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 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