diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2013-12-22 00:07:40 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2013-12-22 00:07:40 +0000 |
commit | bfef399519ca9b8a4b4c6b563253bad7e0eeffe0 (patch) | |
tree | df8df0b0067b381eab470a3b8f28d14a552a6340 /test/Parser | |
parent | 6a0372513edbc473b538d2f724efac50405d6fef (diff) | |
download | src-bfef399519ca9b8a4b4c6b563253bad7e0eeffe0.tar.gz src-bfef399519ca9b8a4b4c6b563253bad7e0eeffe0.zip |
Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3):vendor/clang/clang-release_34-r197841
Notes
Notes:
svn path=/vendor/clang/dist/; revision=259701
svn path=/vendor/clang/clang-release_34-r197841/; revision=259703; tag=vendor/clang/clang-release_34-r197841
Diffstat (limited to 'test/Parser')
36 files changed, 804 insertions, 53 deletions
diff --git a/test/Parser/DelayedTemplateParsing.cpp b/test/Parser/DelayedTemplateParsing.cpp index 77b47239f4c8..73128c49f247 100644 --- a/test/Parser/DelayedTemplateParsing.cpp +++ b/test/Parser/DelayedTemplateParsing.cpp @@ -11,7 +11,8 @@ class A { template <class T> class B { void foo4() { } // expected-note {{previous definition is here}} expected-note {{previous definition is here}} - void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}} expected-note {{previous definition is here}} + void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}} + void foo5() { } // expected-note {{previous definition is here}} friend void foo3() { undeclared(); @@ -20,7 +21,7 @@ class B { template <class T> -void B<T>::foo4() {// expected-error {{redefinition of 'foo4'}} +void B<T>::foo5() { // expected-error {{redefinition of 'foo5'}} } template <class T> @@ -101,3 +102,22 @@ namespace rdar11700604 { }; } +namespace PR17334 { + +template <typename = void> struct ArrayRef { + constexpr ArrayRef() {} +}; +template <typename = void> void CreateConstInBoundsGEP2_32() { + ArrayRef<> IdxList; +} +void LLVMBuildStructGEP() { CreateConstInBoundsGEP2_32(); } + +} + +namespace PR17661 { +template <typename T> +constexpr T Fun(T A) { return T(0); } + +constexpr int Var = Fun(20); +} + diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c index 35c63d4b552a..5e1139338b81 100644 --- a/test/Parser/MicrosoftExtensions.c +++ b/test/Parser/MicrosoftExtensions.c @@ -30,6 +30,20 @@ void __forceinline InterlockedBitTestAndSet (long *Base, long Bit) }; #endif } + +// Both inline and __forceinline is OK. +inline void __forceinline pr8264() { +} +__forceinline void inline pr8264_1() { +} +void inline __forceinline pr8264_2() { +} +void __forceinline inline pr8264_3() { +} +// But duplicate __forceinline causes warning. +void __forceinline __forceinline pr8264_4() { // expected-warning{{duplicate '__forceinline' declaration specifier}} +} + _inline int foo99() { return 99; } void test_ms_alignof_alias() { @@ -105,3 +119,14 @@ __declspec() void quux( void ) { struct S7 s; int i = s.t; /* expected-warning {{'t' is deprecated}} */ } + +int * __sptr psp; +int * __uptr pup; +/* Either ordering is acceptable */ +int * __ptr32 __sptr psp32; +int * __ptr32 __uptr pup32; +int * __sptr __ptr64 psp64; +int * __uptr __ptr64 pup64; + +/* Legal to have nested pointer attributes */ +int * __sptr * __ptr32 ppsp32; diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp index d8a597a8cc5b..efb5c3ce1fdc 100644 --- a/test/Parser/MicrosoftExtensions.cpp +++ b/test/Parser/MicrosoftExtensions.cpp @@ -4,21 +4,21 @@ [repeatable][source_annotation_attribute( Parameter|ReturnValue )] struct SA_Post{ SA_Post(); int attr; }; -[returnvalue:SA_Post( attr=1)] +[returnvalue:SA_Post( attr=1)] int foo1([SA_Post(attr=1)] void *param); namespace { - [returnvalue:SA_Post(attr=1)] + [returnvalue:SA_Post(attr=1)] int foo2([SA_Post(attr=1)] void *param); } class T { - [returnvalue:SA_Post(attr=1)] + [returnvalue:SA_Post(attr=1)] int foo3([SA_Post(attr=1)] void *param); }; extern "C" { - [returnvalue:SA_Post(attr=1)] + [returnvalue:SA_Post(attr=1)] int foo5([SA_Post(attr=1)] void *param); } @@ -32,7 +32,7 @@ public: void uuidof_test1() -{ +{ __uuidof(0); // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}} } @@ -44,8 +44,8 @@ typedef struct _GUID 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(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires a string}} +struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires 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}} @@ -59,7 +59,7 @@ struct struct_without_uuid { }; struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) struct_with_uuid2; -struct +struct struct_with_uuid2 {} ; int uuid_sema_test() @@ -72,6 +72,10 @@ int uuid_sema_test() __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(struct_with_uuid[1]); + __uuidof(struct_with_uuid*[1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}} + __uuidof(const struct_with_uuid[1][1]); + __uuidof(const struct_with_uuid*[1][1]); // 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}} @@ -89,16 +93,16 @@ template <class T> void template_uuid() { T expr; - + __uuidof(T); __uuidof(expr); } -template <class T, const GUID* g = &__uuidof(T)> +template <class T, const GUID* g = &__uuidof(T)> // expected-note {{template parameter is declared here}} class COM_CLASS_TEMPLATE { }; -typedef COM_CLASS_TEMPLATE<struct_with_uuid, &__uuidof(struct_with_uuid)> COM_TYPE_1; +typedef COM_CLASS_TEMPLATE<struct_with_uuid, &*&__uuidof(struct_with_uuid)> COM_TYPE_1; // expected-warning {{non-type template argument containing a dereference operation is a Microsoft extension}} typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2; template <class T, const GUID& g> @@ -112,8 +116,30 @@ typedef COM_CLASS_TEMPLATE_REF<struct_with_uuid, __uuidof(struct_with_uuid)> COM } struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) late_defined_uuid; +COM_CLASS_TEMPLATE_REF<int, __uuidof(struct_with_uuid)> good_template_arg; + +COM_CLASS_TEMPLATE<int, __uuidof(struct_with_uuid)> bad_template_arg; // expected-error {{non-type template argument of type 'const _GUID' is not a constant expression}} + +namespace PR16911 { +struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid; +struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid2; + +template <typename T, typename T2> +struct thing { +}; + +struct empty {}; +struct inher : public thing<empty, uuid2> {}; -class CtorCall { +struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid; +const struct _GUID *w = &__uuidof(inher); // expected-error{{cannot call operator __uuidof on a type with no GUID}} +const struct _GUID *x = &__uuidof(thing<uuid, inher>); +const struct _GUID *y = &__uuidof(thing<uuid2, uuid>); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}} +thing<uuid2, uuid> thing_obj = thing<uuid2, uuid>(); +const struct _GUID *z = &__uuidof(thing_obj); // expected-error{{cannot call operator __uuidof on a type with multiple GUIDs}} +} + +class CtorCall { public: CtorCall& operator=(const CtorCall& that); @@ -136,7 +162,7 @@ public: class Iterator { }; }; - + template<class T> class C2 { typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}} @@ -149,7 +175,9 @@ void missing_template_keyword(){ -class AAAA { }; +class AAAA { + typedef int D; +}; template <typename T> class SimpleTemplate {}; @@ -160,7 +188,7 @@ void redundant_typename() { typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}} t = 3; - + typedef typename T* pointerT;// expected-warning {{expected a qualified name after 'typename'}} typedef typename SimpleTemplate<int> templateT;// expected-warning {{expected a qualified name after 'typename'}} @@ -171,6 +199,12 @@ void redundant_typename() { int k = typename var;// expected-error {{expected a qualified name after 'typename'}} } +template <typename T> +struct TypenameWrongPlace { + typename typedef T::D D;// expected-warning {{expected a qualified name after 'typename'}} +}; + +extern TypenameWrongPlace<AAAA> PR16925; __interface MicrosoftInterface; __interface MicrosoftInterface { @@ -239,25 +273,25 @@ __if_not_exists(IF_EXISTS::Type_not) { int __if_exists_init_list() { int array1[] = { - 0, + 0, __if_exists(IF_EXISTS::Type) {2, } 3 }; int array2[] = { - 0, + 0, __if_exists(IF_EXISTS::Type_not) { this wont compile } 3 }; int array3[] = { - 0, + 0, __if_not_exists(IF_EXISTS::Type_not) {2, } 3 }; int array4[] = { - 0, + 0, __if_not_exists(IF_EXISTS::Type) { this wont compile } 3 }; @@ -297,10 +331,19 @@ class inline_definition_pure_spec { virtual int f2() = 0; }; +struct pure_virtual_dtor { + virtual ~pure_virtual_dtor() = 0; +}; +pure_virtual_dtor::~pure_virtual_dtor() { } + +struct pure_virtual_dtor_inline { + virtual ~pure_virtual_dtor_inline() = 0 { }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} +}; + int main () { // Necessary to force instantiation in -fdelayed-template-parsing mode. - test_late_defined_uuid<int>(); + test_late_defined_uuid<int>(); redundant_typename<int>(); missing_template_keyword<int>(); } diff --git a/test/Parser/PR11000.cpp b/test/Parser/PR11000.cpp index 7dae99621bbb..8d235cdf0316 100644 --- a/test/Parser/PR11000.cpp +++ b/test/Parser/PR11000.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -std=c++11 %s 2>&1 | FileCheck %s // PR11000: Don't crash. class tuple<> diff --git a/test/Parser/altivec-csk-bool.c b/test/Parser/altivec-csk-bool.c new file mode 100644 index 000000000000..ba6fa3b2f77b --- /dev/null +++ b/test/Parser/altivec-csk-bool.c @@ -0,0 +1,14 @@ +// RUN: %clang -target powerpc64-unknown-linux-gnu -maltivec -fsyntax-only %s + +// PR16456: Verify that bool, true, false are treated as context-sensitive +// keywords (and therefore available for use as identifiers) when in +// Altivec mode. + +typedef enum { + false_value = 0, + true_value = 1 +} bool; + +#define true true_value +#define false false_value + diff --git a/test/Parser/attr-availability.c b/test/Parser/attr-availability.c index 0ed839177531..06bebbad5c59 100644 --- a/test/Parser/attr-availability.c +++ b/test/Parser/attr-availability.c @@ -18,6 +18,8 @@ void f5() __attribute__((availability(macosx,introduced=10.5), availability(ios, void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}} +void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}} + // rdar://10095131 enum E{ gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), // expected-error {{expected string literal for optional message in 'availability' attribute}} diff --git a/test/Parser/attributes.c b/test/Parser/attributes.c index 347cb9c1bfbf..376ed2e7d2c9 100644 --- a/test/Parser/attributes.c +++ b/test/Parser/attributes.c @@ -58,7 +58,7 @@ void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn)); void __attribute__((returns_twice)) returns_twice_test(); int aligned(int); -int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error {{expected ')'}} +int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error 2{{expected ')'}} expected-note {{to match}} expected-warning {{does not declare anything}} int __attribute__((mode(x aligned(16) )) missing_rparen_2; // expected-error {{expected ')'}} int __attribute__((format(printf, 0 aligned(16) )) missing_rparen_3; // expected-error {{expected ')'}} diff --git a/test/Parser/crash-report.c b/test/Parser/crash-report.c index 42481aa7d003..6f3706299d1b 100644 --- a/test/Parser/crash-report.c +++ b/test/Parser/crash-report.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s 2>&1 | FileCheck %s +// RUN: not --crash %clang_cc1 %s 2>&1 | FileCheck %s // REQUIRES: crash-recovery #prag\ diff --git a/test/Parser/cxx-altivec.cpp b/test/Parser/cxx-altivec.cpp index 9b2b1af22f6e..be00e494fd53 100644 --- a/test/Parser/cxx-altivec.cpp +++ b/test/Parser/cxx-altivec.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify -std=c++11 %s __vector char vv_c; __vector signed char vv_sc; @@ -168,3 +168,7 @@ 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}} + +template<typename... Args> void PR16874() { + (void) (Args::foo()...); // expected-error {{expression contains unexpanded parameter pack 'Args'}} expected-error {{expected ')'}} expected-note {{to match this '('}} +} diff --git a/test/Parser/cxx-ambig-init-templ.cpp b/test/Parser/cxx-ambig-init-templ.cpp new file mode 100644 index 000000000000..ac79f77e152d --- /dev/null +++ b/test/Parser/cxx-ambig-init-templ.cpp @@ -0,0 +1,171 @@ +// RUN: %clang_cc1 -Wno-uninitialized -std=c++11 -verify %s + +template<int> struct c { c(int) = delete; typedef void val; operator int() const; }; + +int val; +int foobar; +struct S { + int k1 = a < b < c, d > ::val, e1; + int k2 = a < b, c < d > ::val, e2; + int k3 = b < a < c, d > ::val, e3; + int k4 = b < c, x, y = d > ::val, e4; + int k5 = T1 < b, &S::operator=(int); // expected-error {{extra qualification}} + int k6 = T2 < b, &S::operator= >::val; + int k7 = T1 < b, &S::operator>(int); // expected-error {{extra qualification}} + int k8 = T2 < b, &S::operator> >::val; + int k9 = T3 < a < b, c >> (d), e5 = 1 > (e4); + int k10 = 0 < T3 < a < b, c >> (d + ) // expected-error {{expected ';' at end of declaration}} + , a > (e4); + int k11 = 0 < 1, c<3>::*ptr; + int k12 = e < 0, int a<b<c>::* >(), e11; + + void f1( + int k1 = a < b < c, d > ::val, + int k2 = b < a < c, d > ::val, + int k3 = b < c, int x = 0 > ::val, + int k4 = a < b, T3 < int > >(), // expected-error {{must be an expression}} + int k5 = a < b, c < d > ::val, + int k6 = a < b, c < d > (n) // expected-error {{undeclared identifier 'n'}} + ); + + void f2a( + // T3<int> here is a parameter type, so must be declared before it is used. + int k1 = c < b, T3 < int > x = 0 // expected-error {{unexpected end of default argument expression}} + ); + + template<typename, int=0> struct T3 { T3(int); operator int(); }; + + void f2b( + int k1 = c < b, T3 < int > x = 0 // ok + ); + + // This is a one-parameter function. Ensure we don't typo-correct it to + // int = a < b, c < foobar > () + // ... which would be a function with two parameters. + int f3(int = a < b, c < goobar > ()); + static constexpr int (S::*f3_test)(int) = &S::f3; + + void f4( + int k1 = a<1,2>::val, + int missing_default // expected-error {{missing default argument on parameter}} + ); + + void f5( + int k1 = b < c, + int missing_default // expected-error {{missing default argument on parameter}} + ); + + void f6( + int k = b < c, + unsigned int (missing_default) // expected-error {{missing default argument on parameter}} + ); + + template<int, int=0> struct a { static const int val = 0; operator int(); }; // expected-note {{here}} + static const int b = 0, c = 1, d = 2, goobar = 3; + template<int, typename> struct e { operator int(); }; + + int mp1 = 0 < 1, + a<b<c,b<c>::*mp2, + mp3 = 0 > a<b<c>::val, + a<b<c,b<c>::*mp4 = 0, + a<b<c,b<c>::*mp5 {0}, + a<b<c,b<c>::*mp6; + + int np1 = e<0, int a<b<c,b<c>::*>(); + + static const int T1 = 4; + template<int, int &(S::*)(int)> struct T2 { static const int val = 0; }; +}; + +namespace NoAnnotationTokens { + template<bool> struct Bool { Bool(int); }; + static const bool in_class = false; + + struct Test { + // Check we don't keep around a Bool<false> annotation token here. + int f(Bool<true> = X<Y, Bool<in_class> >(0)); + + // But it's OK if we do here. + int g(Bool<true> = Z<Y, Bool<in_class> = Bool<false>(0)); + + static const bool in_class = true; + template<int, typename U> using X = U; + static const int Y = 0, Z = 0; + }; +} + +namespace ImplicitInstantiation { + template<typename T> struct HasError { typename T::error error; }; // expected-error {{has no members}} + + struct S { + // This triggers the instantiation of the outer HasError<int> during + // disambiguation, even though it uses the inner HasError<int>. + void f(int a = X<Y, HasError<int>::Z >()); // expected-note {{in instantiation of}} + + template<typename, typename> struct X { operator int(); }; + typedef int Y; + template<typename> struct HasError { typedef int Z; }; + }; + + HasError<int> hei; +} + +namespace CWG325 { + template <int A, typename B> struct T { static int i; operator int(); }; + class C { + int Foo (int i = T<1, int>::i); + }; + + class D { + int Foo (int i = T<1, int>::i); + template <int A, typename B> struct T {static int i;}; + }; + + const int a = 0; + typedef int b; + T<a,b> c; + struct E { + int n = T<a,b>(c); + }; +} + +namespace Operators { + struct Y {}; + constexpr int operator,(const Y&, const Y&) { return 8; } + constexpr int operator>(const Y&, const Y&) { return 8; } + constexpr int operator<(const Y&, const Y&) { return 8; } + constexpr int operator>>(const Y&, const Y&) { return 8; } + + struct X { + typedef int (*Fn)(const Y&, const Y&); + + Fn a = operator,, b = operator<, c = operator>; + void f(Fn a = operator,, Fn b = operator<, Fn c = operator>); + + int k1 = T1<0, operator<, operator>, operator<>::val, l1; + int k2 = T1<0, operator>, operator,, operator,>::val, l2; + int k3 = T2<0, operator,(Y{}, Y{}), operator<(Y{}, Y{})>::val, l3; + int k4 = T2<0, operator>(Y{}, Y{}), operator,(Y{}, Y{})>::val, l4; + int k5 = T3<0, operator>>>::val, l5; + int k6 = T4<0, T3<0, operator>>>>::val, l6; + + template<int, Fn, Fn, Fn> struct T1 { enum { val }; }; + template<int, int, int> struct T2 { enum { val }; }; + template<int, Fn> struct T3 { enum { val }; }; + template<int, typename T> struct T4 : T {}; + }; +} + +namespace ElaboratedTypeSpecifiers { + struct S { + int f(int x = T<a, struct S>()); + int g(int x = T<a, class __declspec() C>()); + int h(int x = T<a, union __attribute__(()) U>()); + int i(int x = T<a, enum E>()); + int j(int x = T<a, struct S::template T<0, enum E>>()); + template <int, typename> struct T { operator int(); }; + static const int a = 0; + enum E {}; + }; +} diff --git a/test/Parser/cxx-attributes.cpp b/test/Parser/cxx-attributes.cpp index 5ea0ce227595..6fd7f4f68a46 100644 --- a/test/Parser/cxx-attributes.cpp +++ b/test/Parser/cxx-attributes.cpp @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics class c { virtual void f1(const char* a, ...) @@ -8,3 +7,16 @@ class c { __attribute__ (( __format__(__printf__,2,3) )) {} }; +template <typename T> class X { + template <typename S> void X<S>::f() __attribute__((locks_excluded())); // expected-error{{nested name specifier 'X<S>::' for declaration does not refer into a class, class template or class template partial specialization}} \ + // expected-warning{{attribute locks_excluded ignored, because it is not attached to a declaration}} +}; + +namespace PR17666 { + const int A = 1; + typedef int __attribute__((__aligned__(A))) T1; + int check1[__alignof__(T1) == 1 ? 1 : -1]; + + typedef int __attribute__((aligned(int(1)))) T1; + typedef int __attribute__((aligned(int))) T2; // expected-error {{expected '(' for function-style cast}} +} diff --git a/test/Parser/cxx-class-template-specialization.cpp b/test/Parser/cxx-class-template-specialization.cpp new file mode 100644 index 000000000000..f94a85964a78 --- /dev/null +++ b/test/Parser/cxx-class-template-specialization.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct A { + template<typename T> + void f(); +}; +class A::f<int>; +// expected-error@-1 {{identifier followed by '<' indicates a class template specialization but 'f' refers to a function template}} diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index 41d305b17642..8c4c6175f5c5 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -108,9 +108,9 @@ template<class T> class Class1; class Class2 { -} // no ; +} // expected-error {{expected ';' after class}} -typedef Class1<Class2> Type1; // expected-error {{cannot combine with previous 'class' declaration specifier}} +typedef Class1<Class2> Type1; // rdar : // 8307865 struct CodeCompleteConsumer { @@ -187,6 +187,51 @@ namespace PR15017 { // Ensure we produce at least some diagnostic for attributes in C++98. [[]] struct S; // expected-error 2{{}} +namespace test7 { + struct Foo { + void a(); + void b(); + }; + + void Foo:: + // Comment! + a() {} + + + void Foo:: // expected-error {{expected unqualified-id}} + // Comment! +} + +void test8() { + struct {} o; + // This used to crash. + (&o)->(); // expected-error{{expected unqualified-id}} +} + +namespace PR5066 { + template<typename T> struct X {}; + X<int N> x; // expected-error {{type-id cannot have a name}} + + using T = int (*T)(); // expected-error {{type-id cannot have a name}} expected-warning {{C++11}} +} + +namespace PR17255 { +void foo() { + typename A::template B<>; // expected-error {{use of undeclared identifier 'A'}} \ + // expected-error {{expected a qualified name after 'typename'}} \ + // expected-warning {{'template' keyword outside of a template}} +} +} + +namespace PR17567 { + struct Foobar { // expected-note 2{{declared here}} + FooBar(); // expected-error {{missing return type for function 'FooBar'; did you mean the constructor name 'Foobar'?}} + ~FooBar(); // expected-error {{expected the class name after '~' to name a destructor}} + }; + FooBar::FooBar() {} // expected-error {{undeclared}} expected-error {{missing return type}} + FooBar::~FooBar() {} // expected-error {{undeclared}} expected-error {{expected the class name}} +} + // PR8380 extern "" // expected-error {{unknown linkage language}} test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \ diff --git a/test/Parser/cxx-default-args.cpp b/test/Parser/cxx-default-args.cpp index 7fe8474142ba..36abf0d8cb38 100644 --- a/test/Parser/cxx-default-args.cpp +++ b/test/Parser/cxx-default-args.cpp @@ -14,3 +14,20 @@ typedef struct Inst { struct X { void f(int x = 1:); // expected-error {{unexpected end of default argument expression}} }; + +// PR13657 +struct T { + template <typename A, typename B> struct T1 { enum {V};}; + template <int A, int B> struct T2 { enum {V}; }; + template <int, int> static int func(int); + + + void f1(T1<int, int> = T1<int, int>()); + void f2(T1<int, double> = T1<int, double>(), T2<0, 5> = T2<0, 5>()); + void f3(int a = T2<0, (T1<int, int>::V > 10) ? 5 : 6>::V, bool b = 4<5 ); + void f4(bool a = 1 < 0, bool b = 2 > 0 ); + void f5(bool a = 1 > T2<0, 0>::V, bool b = T1<int,int>::V < 3, int c = 0); + void f6(bool a = T2<0,3>::V < 4, bool b = 4 > T2<0,3>::V); + void f7(bool a = T1<int, bool>::V < 3); + void f8(int = func<0,1<2>(0), int = 1<0, T1<int,int>(int) = 0); +}; diff --git a/test/Parser/cxx-friend.cpp b/test/Parser/cxx-friend.cpp index a13e7babc534..a3b89cc688bb 100644 --- a/test/Parser/cxx-friend.cpp +++ b/test/Parser/cxx-friend.cpp @@ -30,6 +30,10 @@ class B { void f(A *a) { a->f(); } }; +void bar() {} // expected-note {{previous definition is here}} +class E { + friend void bar() {} // expected-error {{redefinition of 'bar'}} +}; diff --git a/test/Parser/cxx-member-crash.cpp b/test/Parser/cxx-member-crash.cpp index 2b31a608a583..65e70954e043 100644 --- a/test/Parser/cxx-member-crash.cpp +++ b/test/Parser/cxx-member-crash.cpp @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -fsyntax-only %s 2>&1|FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s // <rdar://problem/9221993> -// We only care to chek whether the compiler crashes; the actual +// We only care to check whether the compiler crashes; the actual // diagnostics are uninteresting. // CHECK: 8 errors generated. template<class _CharT> struct char_traits; diff --git a/test/Parser/cxx-member-initializers.cpp b/test/Parser/cxx-member-initializers.cpp index 5c3906836c49..ff8c880a1849 100644 --- a/test/Parser/cxx-member-initializers.cpp +++ b/test/Parser/cxx-member-initializers.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s struct x { x() : a(4) ; // expected-error {{expected '{'}} @@ -11,5 +11,71 @@ struct y { struct z { int a; - z() : a {} // expected-error {{expected '('}} -}; + z() : a {} +}; // expected-error {{expected '{'}} + +namespace PR16480 { + template<int n> struct X { + X(); + X(int); + }; + + struct A : X<0> { + A() : X<a<b>{0}.n>() {} + + template<int> struct a { + int n; + }; + + static const int b = 1; + }; + + struct B : X<0> { + B() : X<a<b>{0} {} + + static const int a = 0, b = 0; + }; + + template<int> struct a { + constexpr a(int) {} + constexpr operator int() const { return 0; } + }; + + struct C : X<0> { + C() : X<a<b>(0)>() {} + + static const int b = 0; + }; + + struct D : X<0> { + D() : X<a<b>(0) {} + + static const int a = 0, b = 0; + }; + + template<typename T> struct E : X<0> { + E(X<0>) : X<(0)>{} {} + E(X<1>) : X<int{}>{} {} + E(X<2>) : X<(0)>() {} + E(X<3>) : X<int{}>() {} + }; + + // FIXME: This should be valid in the union of C99 and C++11. + struct F : X<0> { + F() : X<A<T>().n + (T){}.n>{} {} // expected-error +{{}} + + struct T { int n; }; + template<typename> struct A { int n; }; + }; // expected-error +{{}} + + // FIXME: This is valid now, but may be made ill-formed by DR1607. + struct G : X<0> { + G() : X<0 && [](){return 0;}()>{} // expected-error +{{}} + }; // expected-error +{{}} + + struct Errs : X<0> { + Errs(X<0>) : decltype X<0>() {} // expected-error {{expected '(' after 'decltype'}} + Errs(X<1>) : what is this () {} // expected-error {{expected '(' or '{'}} + Errs(X<2>) : decltype(X<0> // expected-note {{to match this '('}} + }; // expected-error {{expected ')'}} +} diff --git a/test/Parser/cxx-template-argument.cpp b/test/Parser/cxx-template-argument.cpp index afe318df7a1a..8bf2a4f78add 100644 --- a/test/Parser/cxx-template-argument.cpp +++ b/test/Parser/cxx-template-argument.cpp @@ -5,7 +5,7 @@ template<typename T> struct A {}; // Check for template argument lists followed by junk // FIXME: The diagnostics here aren't great... A<int+> int x; // expected-error {{expected '>'}} expected-error {{expected unqualified-id}} -A<int x; // expected-error {{expected '>'}} +A<int x; // expected-error {{type-id cannot have a name}} expected-error {{expected '>'}} // PR8912 template <bool> struct S {}; @@ -42,3 +42,66 @@ namespace PR13210 { new C(); // expected-error {{requires template arguments}} } } + +// Don't emit spurious messages +namespace pr16225add { + + template<class T1, typename T2> struct Known { }; // expected-note 3 {{template is declared here}} + template<class T1, typename T2> struct X; + template<class T1, typename T2> struct ABC; // expected-note {{template is declared here}} + template<int N1, int N2> struct ABC2 {}; + + template<class T1, typename T2> struct foo : + UnknownBase<T1,T2> // expected-error {{unknown template name 'UnknownBase'}} + { }; + + template<class T1, typename T2> struct foo2 : + UnknownBase<T1,T2>, // expected-error {{unknown template name 'UnknownBase'}} + Known<T1> // expected-error {{too few template arguments for class template 'Known'}} + { }; + + template<class T1, typename T2> struct foo3 : + UnknownBase<T1,T2,ABC<T2,T1> > // expected-error {{unknown template name 'UnknownBase'}} + { }; + + template<class T1, typename T2> struct foo4 : + UnknownBase<T1,ABC<T2> >, // expected-error {{unknown template name 'UnknownBase'}} \ + // expected-error {{too few template arguments for class template 'ABC'}} + Known<T1> // expected-error {{too few template arguments for class template 'Known'}} + { }; + + template<class T1, typename T2> struct foo5 : + UnknownBase<T1,T2,ABC<T2,T1>> // expected-error {{unknown template name 'UnknownBase'}} \ + // expected-error {{use '> >'}} + { }; + + template<class T1, typename T2> struct foo6 : + UnknownBase<T1,ABC<T2,T1>>, // expected-error {{unknown template name 'UnknownBase'}} \ + // expected-error {{use '> >'}} + Known<T1> // expected-error {{too few template arguments for class template 'Known'}} + { }; + + template<class T1, typename T2, int N> struct foo7 : + UnknownBase<T1,T2,(N>1)> // expected-error {{unknown template name 'UnknownBase'}} + { }; + + template<class T1, typename T2> struct foo8 : + UnknownBase<X<int,int>,X<int,int>> // expected-error {{unknown template name 'UnknownBase'}} \ + // expected-error {{use '> >'}} + { }; + + template<class T1, typename T2> struct foo9 : + UnknownBase<Known<int,int>,X<int,int>> // expected-error {{unknown template name 'UnknownBase'}} \ + // expected-error {{use '> >'}} + { }; + + template<class T1, typename T2> struct foo10 : + UnknownBase<Known<int,int>,X<int,X<int,int>>> // expected-error {{unknown template name 'UnknownBase'}} \ + // expected-error {{use '> >'}} + { }; + + template<int N1, int N2> struct foo11 : + UnknownBase<2<N1,N2<4> // expected-error {{unknown template name 'UnknownBase'}} + { }; + +} diff --git a/test/Parser/cxx-template-decl.cpp b/test/Parser/cxx-template-decl.cpp index 7e931a31fa2d..81269ce25416 100644 --- a/test/Parser/cxx-template-decl.cpp +++ b/test/Parser/cxx-template-decl.cpp @@ -85,6 +85,19 @@ struct shadow5 { int T(int, float); // expected-error{{shadows}} }; +template<typename T, // expected-note{{template parameter is declared here}} + T T> // expected-error{{declaration of 'T' shadows template parameter}} +void shadow6(); + +template<typename T, // expected-note{{template parameter is declared here}} + template<typename> class T> // expected-error{{declaration of 'T' shadows template parameter}} +void shadow7(); + +// PR8302 +template<template<typename> class T> struct shadow8 { // expected-note{{template parameter is declared here}} + template<template<typename> class T> struct inner; // expected-error{{declaration of 'T' shadows template parameter}} +}; + // Non-type template parameters in scope template<int Size> void f(int& i) { @@ -103,6 +116,7 @@ void f2() { // PR3844 template <> struct S<int> { }; // expected-error{{explicit specialization of non-template struct 'S'}} +template <> union U<int> { }; // expected-error{{explicit specialization of non-template union 'U'}} namespace PR6184 { namespace N { diff --git a/test/Parser/cxx-using-directive.cpp b/test/Parser/cxx-using-directive.cpp index 9a1a6de89267..5efd991c8e7a 100644 --- a/test/Parser/cxx-using-directive.cpp +++ b/test/Parser/cxx-using-directive.cpp @@ -4,11 +4,11 @@ class A {}; namespace B { namespace A {} // expected-note{{namespace '::B::A' defined here}} \ - // expected-note{{namespace 'B::A' defined here}} + // expected-note 2{{namespace 'B::A' defined here}} using namespace A ; } -namespace C {} +namespace C {} // expected-note{{namespace 'C' defined here}} namespace D { @@ -22,12 +22,13 @@ namespace D { using namespace C ; using namespace B::A ; // expected-error{{no namespace named 'A' in namespace 'D::B'; did you mean '::B::A'?}} using namespace ::B::A ; - using namespace ::D::C ; // expected-error{{expected namespace name}} + using namespace ::D::F ; // expected-error{{expected namespace name}} + using namespace ::D::C ; // expected-error{{no namespace named 'C' in namespace 'D'; did you mean simply 'C'?}} } using namespace ! ; // expected-error{{expected namespace name}} using namespace A ; // expected-error{{no namespace named 'A'; did you mean 'B::A'?}} -using namespace ::A // expected-error{{expected namespace name}} \ +using namespace ::A // expected-error{{no namespace named 'A' in the global namespace; did you mean 'B::A'?}} \ // expected-error{{expected ';' after namespace name}} B ; diff --git a/test/Parser/cxx0x-attributes.cpp b/test/Parser/cxx0x-attributes.cpp index 5e4e388a2645..b02add98457e 100644 --- a/test/Parser/cxx0x-attributes.cpp +++ b/test/Parser/cxx0x-attributes.cpp @@ -122,6 +122,24 @@ extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}} [[unknown]] using namespace ns; // expected-warning {{unknown attribute 'unknown' ignored}} [[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions and methods}} +using [[]] alignas(4) [[]] ns::i; // expected-error {{an attribute list cannot appear here}} +using [[]] alignas(4) [[]] foobar = int; // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to}} + +void bad_attributes_in_do_while() { + do {} while ( + [[ns::i); // expected-error {{expected ']'}} \ + // expected-note {{to match this '['}} \ + // expected-error {{expected expression}} + do {} while ( + [[a]b ns::i); // expected-error {{expected ']'}} \ + // expected-note {{to match this '['}} \ + // expected-error {{expected expression}} + do {} while ( + [[ab]ab] ns::i); // expected-error {{an attribute list cannot appear here}} + do {} while ( // expected-note {{to match this '('}} + alignas(4 ns::i; // expected-note {{to match this '('}} +} // expected-error 2{{expected ')'}} expected-error {{expected expression}} + [[]] using T = int; // expected-error {{an attribute list cannot appear here}} using T [[]] = int; // ok template<typename T> using U [[]] = T; @@ -281,3 +299,23 @@ int v5()[[gnu::unused]]; // expected-warning {{attribute 'unused' ignored}} [[attribute_declaration]]; // expected-warning {{unknown attribute 'attribute_declaration' ignored}} [[noreturn]]; // expected-error {{'noreturn' attribute only applies to functions and methods}} [[carries_dependency]]; // expected-error {{'carries_dependency' attribute only applies to functions, methods, and parameters}} + +class A { + A([[gnu::unused]] int a); +}; +A::A([[gnu::unused]] int a) {} + +namespace GccConst { + // GCC's tokenizer treats const and __const as the same token. + [[gnu::const]] int *f1(); + [[gnu::__const]] int *f2(); + void f(const int *); + void g() { f(f1()); f(f2()); } +} + +namespace GccASan { + __attribute__((no_address_safety_analysis)) void f1(); + __attribute__((no_sanitize_address)) void f2(); + [[gnu::no_address_safety_analysis]] void f3(); + [[gnu::no_sanitize_address]] void f4(); +} diff --git a/test/Parser/cxx0x-decl.cpp b/test/Parser/cxx0x-decl.cpp index e6cba726ab63..257c56c9ce98 100644 --- a/test/Parser/cxx0x-decl.cpp +++ b/test/Parser/cxx0x-decl.cpp @@ -73,3 +73,34 @@ enum E [[]] e; } + +namespace PR5066 { + using T = int (*f)(); // expected-error {{type-id cannot have a name}} + template<typename T> using U = int (*f)(); // expected-error {{type-id cannot have a name}} + auto f() -> int (*f)(); // expected-error {{type-id cannot have a name}} + auto g = []() -> int (*f)() {}; // expected-error {{type-id cannot have a name}} +} + +namespace FinalOverride { + struct Base { + virtual void *f(); + virtual void *g(); + virtual void *h(); + virtual void *i(); + }; + struct Derived : Base { + virtual auto f() -> void *final; + virtual auto g() -> void *override; + virtual auto h() -> void *final override; + virtual auto i() -> void *override final; + }; +} + +namespace UsingDeclAttrs { + using T __attribute__((aligned(1))) = int; + using T [[gnu::aligned(1)]] = int; + static_assert(alignof(T) == 1, ""); + + using [[gnu::aligned(1)]] T = int; // expected-error {{an attribute list cannot appear here}} + using T = int [[gnu::aligned(1)]]; // expected-error {{'aligned' attribute cannot be applied to types}} +} diff --git a/test/Parser/cxx0x-in-cxx98.cpp b/test/Parser/cxx0x-in-cxx98.cpp index b4bda89d2781..724993811631 100644 --- a/test/Parser/cxx0x-in-cxx98.cpp +++ b/test/Parser/cxx0x-in-cxx98.cpp @@ -21,3 +21,10 @@ void NewBracedInitList() { // A warning on this would be sufficient once we can handle it correctly. new int {}; // expected-error {{}} } + +struct Auto { + static int n; +}; +auto Auto::n = 0; // expected-warning {{'auto' type specifier is a C++11 extension}} +auto Auto::m = 0; // expected-error {{no member named 'm' in 'Auto'}} + // expected-warning@-1 {{'auto' type specifier is a C++11 extension}} diff --git a/test/Parser/cxx0x-lambda-expressions.cpp b/test/Parser/cxx0x-lambda-expressions.cpp index 642c69a532ee..289d03c223b3 100644 --- a/test/Parser/cxx0x-lambda-expressions.cpp +++ b/test/Parser/cxx0x-lambda-expressions.cpp @@ -48,4 +48,20 @@ class C { delete [] { return new int; } (); // expected-error{{expected expression}} delete [&] { return new int; } (); // ok, lambda } + + // We support init-captures in C++11 as an extension. + int z; + void init_capture() { + [n(0)] () mutable -> int { return ++n; }; // expected-warning{{extension}} + [n{0}] { return; }; // expected-error {{<initializer_list>}} expected-warning{{extension}} + [n = 0] { return ++n; }; // expected-error {{captured by copy in a non-mutable}} expected-warning{{extension}} + [n = {0}] { return; }; // expected-error {{<initializer_list>}} expected-warning{{extension}} + [a([&b = z]{})](){}; // expected-warning 2{{extension}} + + int x = 4; + auto y = [&r = x, x = x + 1]() -> int { // expected-warning 2{{extension}} + r += 2; + return x + 2; + } (); + } }; diff --git a/test/Parser/cxx0x-member-initializers.cpp b/test/Parser/cxx0x-member-initializers.cpp index a324f974bcaf..43e99b133646 100644 --- a/test/Parser/cxx0x-member-initializers.cpp +++ b/test/Parser/cxx0x-member-initializers.cpp @@ -27,3 +27,13 @@ struct V1 { int a, b; V1() : a(), b{} {} }; + +template <typename, typename> struct T1 { enum {V};}; +template <int, int> struct T2 { enum {V};}; +struct A { + T1<int, int> a1 = T1<int, int>(), *a2 = new T1<int,int>; + T2<0,0> b1 = T2<0,0>(), b2 = T2<0,0>(), b3; + bool c1 = 1 < 2, c2 = 2 < 1, c3 = false; + bool d1 = T1<int, T1<int, int>>::V < 3, d2; + T1<int, int()> e = T1<int, int()>(); +}; diff --git a/test/Parser/cxx11-stmt-attributes.cpp b/test/Parser/cxx11-stmt-attributes.cpp index 2f727a25bd7e..9374b58b1f24 100644 --- a/test/Parser/cxx11-stmt-attributes.cpp +++ b/test/Parser/cxx11-stmt-attributes.cpp @@ -76,4 +76,9 @@ void foo(int i) { } [[carries_dependency]] return; // expected-error {{'carries_dependency' attribute cannot be applied to a statement}} + + { + [[ ]] // expected-error {{an attribute list cannot appear here}} +#pragma STDC FP_CONTRACT ON // expected-error {{can only appear at file scope or at the start of a compound statement}} + } } diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c index f63b59f7caa6..210a8e2befc7 100644 --- a/test/Parser/declarators.c +++ b/test/Parser/declarators.c @@ -108,7 +108,8 @@ void test18() { } enum E1 { e1 }: // expected-error {{expected ';'}} -struct EnumBitfield { +struct EnumBitfield { // expected-warning {{struct without named members is a GNU extension}} enum E2 { e2 } : 4; // ok struct S { int n; }: // expected-error {{expected ';'}} + }; diff --git a/test/Parser/expressions.c b/test/Parser/expressions.c index 0d1b6c945c5c..95d6fb354f3f 100644 --- a/test/Parser/expressions.c +++ b/test/Parser/expressions.c @@ -57,3 +57,13 @@ void test7() { ({} // expected-note {{to match}} ; // expected-error {{expected ')'}} } + +// PR16992 +struct pr16992 { int x; }; + +void func_16992 () { + int x1 = sizeof int; // expected-error {{expected parentheses around type name in sizeof expression}} + int x2 = sizeof struct pr16992; // expected-error {{expected parentheses around type name in sizeof expression}} + int x3 = __alignof int; // expected-error {{expected parentheses around type name in __alignof expression}} + int x4 = _Alignof int; // expected-error {{expected parentheses around type name in _Alignof expression}} +} diff --git a/test/Parser/objc-diag-width.mm b/test/Parser/objc-diag-width.mm index 3929ba2b090e..eba7a847de39 100644 --- a/test/Parser/objc-diag-width.mm +++ b/test/Parser/objc-diag-width.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 %s 2>&1 | FileCheck %s // Just shouldn't crash. -verify suppresses the crash, so don't use it. // PR13417 diff --git a/test/Parser/objc-error-qualified-implementation.m b/test/Parser/objc-error-qualified-implementation.m index 444fb5dab44c..8bbd50236027 100644 --- a/test/Parser/objc-error-qualified-implementation.m +++ b/test/Parser/objc-error-qualified-implementation.m @@ -19,3 +19,11 @@ @implementation K <P // expected-error {{@implementation declaration can not be protocol qualified}} @end // expected-error {{expected '>'}} + +// rdar://13920026 +@implementation I (Cat) <P> // expected-error {{@implementation declaration can not be protocol qualified}} +- (void) Meth {} +@end + +@implementation I (Cat1) <P // expected-error {{@implementation declaration can not be protocol qualified}} +@end // expected-error {{expected '>'}} diff --git a/test/Parser/objcxx0x-lambda-expressions.mm b/test/Parser/objcxx0x-lambda-expressions.mm index fb90b16a971f..bef576a9d204 100644 --- a/test/Parser/objcxx0x-lambda-expressions.mm +++ b/test/Parser/objcxx0x-lambda-expressions.mm @@ -1,9 +1,10 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -Wno-c++1y-extensions -std=c++11 %s class C { + id get(int); void f() { - int foo, bar; + int foo, bar, baz; // fail to parse as a lambda introducer, so we get objc message parsing errors instead [foo,+] {}; // expected-error {{expected expression}} @@ -17,6 +18,25 @@ class C { [foo,bar] () { return 3; }; [=,&foo] () {}; [this] () {}; + + [foo(bar)] () {}; + [foo = bar] () {}; + [foo{bar}] () {}; // expected-error {{<initializer_list>}} + [foo = {bar}] () {}; // expected-error {{<initializer_list>}} + + [foo(bar) baz] () {}; // expected-error {{called object type 'int' is not a function}} + [foo(bar), baz] () {}; // ok + + [foo = bar baz]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}} + + [get(bar) baz]; // expected-warning {{instance method '-baz'}} + [get(bar), baz]; // expected-error {{expected body of lambda}} + + [foo = bar ++ baz]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}} + [foo = bar + baz]; // expected-error {{expected body of lambda}} + [foo = { bar, baz }]; // expected-error {{<initializer_list>}} expected-error {{expected body of lambda}} + [foo = { bar } baz ]; // expected-warning {{receiver type 'int'}} expected-warning {{instance method '-baz'}} + [foo = { bar }, baz ]; // expected-error {{<initializer_list>}} expected-error {{expected body of lambda}} } }; diff --git a/test/Parser/parser_overflow.c b/test/Parser/parser_overflow.c index 7a3d6516af4e..9514e808550a 100644 --- a/test/Parser/parser_overflow.c +++ b/test/Parser/parser_overflow.c @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 %s -fsyntax-only -DHUGE 2>&1 | FileCheck %s -// RUN: %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s -// RUN: %clang_cc1 %s -fsyntax-only -fbracket-depth 299 2>&1 | FileCheck %s +// RUN: not %clang_cc1 %s -fsyntax-only -DHUGE 2>&1 | FileCheck %s +// RUN: not %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s +// RUN: not %clang_cc1 %s -fsyntax-only -fbracket-depth 299 2>&1 | FileCheck %s // RUN: %clang_cc1 %s -fsyntax-only -fbracket-depth 300 -// RUN: %clang %s -fsyntax-only -fbracket-depth=299 2>&1 | FileCheck %s +// RUN: not %clang %s -fsyntax-only -fbracket-depth=299 2>&1 | FileCheck %s // RUN: %clang %s -fsyntax-only -fbracket-depth=300 void foo(void) { diff --git a/test/Parser/pragma-fp-contract.c b/test/Parser/pragma-fp-contract.c index 568c0a0a88ba..c80c140ea71f 100644 --- a/test/Parser/pragma-fp-contract.c +++ b/test/Parser/pragma-fp-contract.c @@ -2,7 +2,7 @@ void f1(void) { int x = 0; -/* expected-error@+1 {{'#pragma fp_contract' should only appear at file scope or at the start of a compound expression}} */ +/* expected-error@+1 {{'#pragma fp_contract' can only appear at file scope or at the start of a compound statement}} */ #pragma STDC FP_CONTRACT ON } diff --git a/test/Parser/pragma-weak.c b/test/Parser/pragma-weak.c index 7e5740b48308..fd47dd8696b8 100644 --- a/test/Parser/pragma-weak.c +++ b/test/Parser/pragma-weak.c @@ -15,3 +15,30 @@ extern int z; extern int a; /* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a b /* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a = x c + + +void pragma_is_not_a_statement(int x) +{ + int t; + + { + if (x) +#pragma weak t + else // expected-error {{expected expression}} +#pragma weak t + } + + switch (x) { + case 1: +#pragma weak t + } // expected-error {{expected statement}} + switch(x) { + default: +#pragma weak t + } // expected-error {{expected statement}} + +label: +#pragma weak t +} // expected-error {{expected statement}} + + diff --git a/test/Parser/recovery.cpp b/test/Parser/recovery.cpp index 41845fb29158..b5b09484ad9e 100644 --- a/test/Parser/recovery.cpp +++ b/test/Parser/recovery.cpp @@ -12,7 +12,7 @@ inline namespace Std { // expected-error {{cannot be reopened as inline}} int x; Std::Important y; -extenr "C" { // expected-error {{did you mean the keyword 'extern'}} +extenr "C" { // expected-error {{did you mean 'extern'}} void f(); } void g() { @@ -35,11 +35,27 @@ constexpr int foo(); 5int m = { l }, n = m; // expected-error {{unqualified-id}} +namespace MissingBrace { + struct S { // expected-error {{missing '}' at end of definition of 'MissingBrace::S'}} + int f(); + // }; + + namespace N { int g(); } // expected-note {{still within definition of 'MissingBrace::S' here}} + + int k1 = S().h(); // expected-error {{no member named 'h' in 'MissingBrace::S'}} + int k2 = S().f() + N::g(); + + template<typename T> struct PR17949 { // expected-error {{missing '}' at end of definition of 'MissingBrace::PR17949'}} + + namespace X { // expected-note {{still within definition of 'MissingBrace::PR17949' here}} + } +} + namespace N { int } // expected-error {{unqualified-id}} -strcut Uuuu { // expected-error {{did you mean the keyword 'struct'}} \ +strcut Uuuu { // expected-error {{did you mean 'struct'}} \ // expected-note {{'Uuuu' declared here}} } *u[3]; uuuu v; // expected-error {{did you mean 'Uuuu'}} @@ -50,3 +66,56 @@ struct Redefined { // expected-note {{previous}} struct Redefined { // expected-error {{redefinition}} Redefined() {} }; + +struct MissingSemi5; +namespace N { + typedef int afterMissingSemi4; + extern MissingSemi5 afterMissingSemi5; +} + +struct MissingSemi1 {} // expected-error {{expected ';' after struct}} +static int afterMissingSemi1(); + +class MissingSemi2 {} // expected-error {{expected ';' after class}} +MissingSemi1 *afterMissingSemi2; + +enum MissingSemi3 {} // expected-error {{expected ';' after enum}} +::MissingSemi1 afterMissingSemi3; + +extern N::afterMissingSemi4 afterMissingSemi4b; +union MissingSemi4 { MissingSemi4(int); } // expected-error {{expected ';' after union}} +N::afterMissingSemi4 (afterMissingSemi4b); + +int afterMissingSemi5b; +struct MissingSemi5 { MissingSemi5(int); } // ok, no missing ';' here +N::afterMissingSemi5 (afterMissingSemi5b); + +template<typename T> struct MissingSemiT { +} // expected-error {{expected ';' after struct}} +MissingSemiT<int> msi; + +struct MissingSemiInStruct { + struct Inner1 {} // expected-error {{expected ';' after struct}} + static MissingSemi5 ms1; + + struct Inner2 {} // ok, no missing ';' here + static MissingSemi1; + + struct Inner3 {} // expected-error {{expected ';' after struct}} + static MissingSemi5 *p; +}; + +void MissingSemiInFunction() { + struct Inner1 {} // expected-error {{expected ';' after struct}} + if (true) {} + + // FIXME: It would be nice to at least warn on this. + struct Inner2 { Inner2(int); } // ok, no missing ';' here + k = l; + + struct Inner3 {} // expected-error {{expected ';' after struct}} + Inner1 i1; + + struct Inner4 {} // ok, no missing ';' here + Inner5; +} diff --git a/test/Parser/switch-recovery.cpp b/test/Parser/switch-recovery.cpp index 84ac0c899e55..63b580202af8 100644 --- a/test/Parser/switch-recovery.cpp +++ b/test/Parser/switch-recovery.cpp @@ -95,7 +95,7 @@ int test8( foo x ) { } // Stress test to make sure Clang doesn't crash. -void test9(int x) { +void test9(int x) { // expected-note {{'x' declared here}} switch(x) { case 1: return; 2: case; // expected-error {{expected 'case' keyword before expression}} \ @@ -104,8 +104,8 @@ void test9(int x) { 7: :x; // expected-error {{expected 'case' keyword before expression}} \ expected-error {{expected expression}} 8:: x; // expected-error {{expected ';' after expression}} \ - expected-error {{no member named 'x' in the global namespace}} \ - expected-warning {{expression result unused}} + expected-error {{no member named 'x' in the global namespace; did you mean simply 'x'?}} \ + expected-warning 2 {{expression result unused}} 9:: :y; // expected-error {{expected ';' after expression}} \ expected-error {{expected unqualified-id}} \ expected-warning {{expression result unused}} |