summaryrefslogtreecommitdiff
path: root/test/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'test/Parser')
-rw-r--r--test/Parser/MicrosoftExtensions.c8
-rw-r--r--test/Parser/MicrosoftExtensions.cpp20
-rw-r--r--test/Parser/PR21872.cpp4
-rw-r--r--test/Parser/access-spec-attrs.cpp1
-rw-r--r--test/Parser/altivec.c31
-rw-r--r--test/Parser/asm.cpp1
-rw-r--r--test/Parser/atomic.c3
-rw-r--r--test/Parser/attributes.c10
-rw-r--r--test/Parser/c11-noreturn.c4
-rw-r--r--test/Parser/c1x-alignas.c2
-rw-r--r--test/Parser/colon-colon-parentheses.cpp10
-rw-r--r--test/Parser/cxx-altivec.cpp17
-rw-r--r--test/Parser/cxx-ambig-init-templ.cpp6
-rw-r--r--test/Parser/cxx-attributes.cpp2
-rw-r--r--test/Parser/cxx-class.cpp48
-rw-r--r--test/Parser/cxx-default-args.cpp10
-rw-r--r--test/Parser/cxx-member-initializers.cpp30
-rw-r--r--test/Parser/cxx-template-argument.cpp5
-rw-r--r--test/Parser/cxx-template-decl.cpp28
-rw-r--r--test/Parser/cxx-variadic-func.cpp7
-rw-r--r--test/Parser/cxx0x-attributes.cpp16
-rw-r--r--test/Parser/cxx0x-decl.cpp10
-rw-r--r--test/Parser/cxx0x-in-cxx98.cpp4
-rw-r--r--test/Parser/cxx0x-lambda-expressions.cpp17
-rw-r--r--test/Parser/cxx11-templates.cpp46
-rw-r--r--test/Parser/cxx1z-attributes.cpp14
-rw-r--r--test/Parser/cxx1z-fold-expressions.cpp29
-rw-r--r--test/Parser/cxx1z-nested-namespace-definition.cpp38
-rw-r--r--test/Parser/debugger-import-module.m6
-rw-r--r--test/Parser/declarators.c4
-rw-r--r--test/Parser/eof2.cpp15
-rw-r--r--test/Parser/ms-if-exists.c87
-rw-r--r--test/Parser/ms-inline-asm.c5
-rw-r--r--test/Parser/namespaces.cpp6
-rw-r--r--test/Parser/nested-namespaces-recovery.cpp24
-rw-r--r--test/Parser/opencl-cl20.cl26
-rw-r--r--test/Parser/pragma-loop.cpp147
-rw-r--r--test/Parser/pragma-unroll.cpp72
-rw-r--r--test/Parser/switch-recovery.cpp9
-rw-r--r--test/Parser/vsx.c10
40 files changed, 731 insertions, 101 deletions
diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c
index d7ea20bca01c8..ea25ccd1af332 100644
--- a/test/Parser/MicrosoftExtensions.c
+++ b/test/Parser/MicrosoftExtensions.c
@@ -85,3 +85,11 @@ int * __uptr __ptr64 pup64;
/* Legal to have nested pointer attributes */
int * __sptr * __ptr32 ppsp32;
+
+// Ignored type qualifiers after comma in declarator lists
+typedef int ignored_quals_dummy1, const volatile __ptr32 __ptr64 __w64 __unaligned __sptr __uptr ignored_quals1; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy2)(), __fastcall ignored_quals2; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy3)(), __stdcall ignored_quals3; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy4)(), __thiscall ignored_quals4; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy5)(), __cdecl ignored_quals5; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy6)(), __vectorcall ignored_quals6; // expected-warning {{qualifiers after comma in declarator list are ignored}}
diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp
index 0174ec2f292de..73a1bb57af36c 100644
--- a/test/Parser/MicrosoftExtensions.cpp
+++ b/test/Parser/MicrosoftExtensions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple i386-mingw32 -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
+// RUN: %clang_cc1 %s -triple i386-mingw32 -std=c++11 -fsyntax-only -Wno-unused-getter-return-value -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
/* Microsoft attribute tests */
[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
@@ -208,12 +208,12 @@ extern TypenameWrongPlace<AAAA> PR16925;
__interface MicrosoftInterface;
__interface MicrosoftInterface {
- void foo1() = 0;
+ void foo1() = 0; // expected-note {{overridden virtual function is here}}
virtual void foo2() = 0;
};
__interface MicrosoftDerivedInterface : public MicrosoftInterface {
- void foo1();
+ void foo1(); // expected-warning {{'foo1' overrides a member function but is not marked 'override'}}
void foo2() override;
void foo3();
};
@@ -226,6 +226,11 @@ void interface_test() {
}
__int64 x7 = __int64(0);
+_int64 x8 = _int64(0);
+static_assert(sizeof(_int64) == 8, "");
+static_assert(sizeof(_int32) == 4, "");
+static_assert(sizeof(_int16) == 2, "");
+static_assert(sizeof(_int8) == 1, "");
int __identifier(generic) = 3;
int __identifier(int) = 4;
@@ -315,6 +320,7 @@ struct StructWithProperty {
__declspec(property(get=GetV,)) int V10; // expected-error {{expected 'get' or 'put' in property declaration}}
__declspec(property(get=GetV,put=SetV)) int V11; // no-warning
__declspec(property(get=GetV,put=SetV,get=GetV)) int V12; // expected-error {{property declaration specifies 'get' accessor twice}}
+ __declspec(property(get=GetV)) int V13 = 3; // expected-error {{property declaration cannot have an in-class initializer}}
int GetV() { return 123; }
void SetV(int v) {}
@@ -361,3 +367,11 @@ void foo(void) {
template <int *>
struct NullptrArg {};
NullptrArg<nullptr> a;
+
+// Ignored type qualifiers after comma in declarator lists
+typedef int ignored_quals_dummy1, const volatile __ptr32 __ptr64 __w64 __unaligned __sptr __uptr ignored_quals1; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy2)(), __fastcall ignored_quals2; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy3)(), __stdcall ignored_quals3; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy4)(), __thiscall ignored_quals4; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy5)(), __cdecl ignored_quals5; // expected-warning {{qualifiers after comma in declarator list are ignored}}
+typedef void(*ignored_quals_dummy6)(), __vectorcall ignored_quals6; // expected-warning {{qualifiers after comma in declarator list are ignored}}
diff --git a/test/Parser/PR21872.cpp b/test/Parser/PR21872.cpp
new file mode 100644
index 0000000000000..ae0a13d9c1ea2
--- /dev/null
+++ b/test/Parser/PR21872.cpp
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 -fsyntax-only %s
+template <typename T> struct S {
+ int k = ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
+int f;
diff --git a/test/Parser/access-spec-attrs.cpp b/test/Parser/access-spec-attrs.cpp
index 4fa5975811651..2958e385f8b51 100644
--- a/test/Parser/access-spec-attrs.cpp
+++ b/test/Parser/access-spec-attrs.cpp
@@ -5,6 +5,7 @@ public __attribute__((unavailable)): // expected-error {{access specifier can on
void foo();
private __attribute__((annotate("foobar"))):
void bar();
+private __attribute__((annotate())): // expected-error {{'annotate' attribute takes one argument}}
};
void f(X x) {
diff --git a/test/Parser/altivec.c b/test/Parser/altivec.c
index 0b8147a3b7b0f..d852511fc06d1 100644
--- a/test/Parser/altivec.c
+++ b/test/Parser/altivec.c
@@ -18,6 +18,9 @@ __vector float vv_f;
__vector bool char vv_bc;
__vector bool short vv_bs;
__vector bool int vv_bi;
+__vector __bool char vv___bc;
+__vector __bool short vv___bs;
+__vector __bool int vv_bi;
__vector __pixel vv_p;
__vector pixel vv__p;
__vector int vf__r();
@@ -40,6 +43,9 @@ vector float v_f;
vector bool char v_bc;
vector bool short v_bs;
vector bool int v_bi;
+vector __bool char v___bc;
+vector __bool short v___bs;
+vector __bool int v___bi;
vector __pixel v_p;
vector pixel v__p;
vector int f__r();
@@ -61,15 +67,16 @@ vector unsigned long v_ul; // expected-warning {{Use of 'long' with '__
vector long int v_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
vector signed long int v_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
vector unsigned long int v_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector long double vv_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
-vector long double v_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+__vector long double vv_ld; // expected-error {{cannot use 'long double' with '__vector'}}
+vector long double v_ld; // expected-error {{cannot use 'long double' with '__vector'}}
vector bool v_b; // expected-warning {{type specifier missing, defaults to 'int'}}
+vector __bool v___b; // expected-warning {{type specifier missing, defaults to 'int'}}
// These should have errors.
-__vector double vv_d1; // expected-error {{cannot use 'double' with '__vector'}}
-vector double v_d2; // expected-error {{cannot use 'double' with '__vector'}}
-__vector long double vv_ld3; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
-vector long double v_ld4; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+__vector double vv_d1; // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on the POWER7 or later)}}
+vector double v_d2; // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on the POWER7 or later)}}
+__vector long double vv_ld3; // expected-error {{cannot use 'long double' with '__vector'}}
+vector long double v_ld4; // expected-error {{cannot use 'long double' with '__vector'}}
vector bool float v_bf; // expected-error {{cannot use 'float' with '__vector bool'}}
vector bool double v_bd; // expected-error {{cannot use 'double' with '__vector bool'}}
vector bool pixel v_bp; // expected-error {{cannot use '__pixel' with '__vector bool'}}
@@ -77,6 +84,18 @@ vector bool signed char v_bsc; // expected-error {{cannot use 'signed' wit
vector bool unsigned int v_bsc2; // expected-error {{cannot use 'unsigned' with '__vector bool'}}
vector bool long v_bl; // expected-error {{cannot use 'long' with '__vector bool'}}
vector bool long long v_bll; // expected-error {{cannot use 'long long' with '__vector bool'}}
+vector __bool float v___bf; // expected-error {{cannot use 'float' with '__vector bool'}}
+vector __bool double v___bd; // expected-error {{cannot use 'double' with '__vector bool'}}
+vector __bool pixel v___bp; // expected-error {{cannot use '__pixel' with '__vector bool'}}
+vector __bool signed char v___bsc; // expected-error {{cannot use 'signed' with '__vector bool'}}
+vector __bool unsigned int v___bsc2; // expected-error {{cannot use 'unsigned' with '__vector bool'}}
+vector __bool long v___bl; // expected-error {{cannot use 'long' with '__vector bool'}}
+vector __bool long long v___bll; // expected-error {{cannot use 'long long' with '__vector bool'}}
+
+// vector long is deprecated, but vector long long is not.
+vector long long v_ll;
+vector signed long long v_sll;
+vector unsigned long long v_ull;
typedef char i8;
typedef short i16;
diff --git a/test/Parser/asm.cpp b/test/Parser/asm.cpp
index 35a497c83a1e8..9f64dfea476ed 100644
--- a/test/Parser/asm.cpp
+++ b/test/Parser/asm.cpp
@@ -6,3 +6,4 @@ int foo3 asm (u8"bar3"); // expected-error {{cannot use unicode string literal i
int foo4 asm (u"bar4"); // expected-error {{cannot use unicode string literal in 'asm'}}
int foo5 asm (U"bar5"); // expected-error {{cannot use unicode string literal in 'asm'}}
int foo6 asm ("bar6"_x); // expected-error {{string literal with user-defined suffix cannot be used here}}
+int foo6 asm ("" L"bar7"); // expected-error {{cannot use wide string literal in 'asm'}}
diff --git a/test/Parser/atomic.c b/test/Parser/atomic.c
index 432deeb59c12f..07a83dddcd3c9 100644
--- a/test/Parser/atomic.c
+++ b/test/Parser/atomic.c
@@ -33,3 +33,6 @@ typedef _Atomic(int) __attribute__((address_space(1))) atomic_addr_space_int;
typedef _Atomic int __attribute__((vector_size(16))) atomic_vector_int;
typedef _Atomic(int __attribute__((vector_size(16)))) atomic_vector_int;
+
+struct S
+_Atomic atomic_s_no_missing_semicolon;
diff --git a/test/Parser/attributes.c b/test/Parser/attributes.c
index 3d69c72c322cd..b815b8da3dc6e 100644
--- a/test/Parser/attributes.c
+++ b/test/Parser/attributes.c
@@ -95,3 +95,13 @@ void testFundef5() __attribute__(()) { }
__attribute__((pure)) int testFundef6(int a) { return a; }
void deprecatedTestFun(void) __attribute__((deprecated()));
+
+struct s {
+ int a;
+};
+
+// This test ensure compatibility with parsing GNU-style attributes
+// where the attribute is on a separate line from the elaborated type
+// specifier.
+struct s
+__attribute__((used)) bar;
diff --git a/test/Parser/c11-noreturn.c b/test/Parser/c11-noreturn.c
index e61901dfb7918..9b932abeaff2f 100644
--- a/test/Parser/c11-noreturn.c
+++ b/test/Parser/c11-noreturn.c
@@ -1,10 +1,10 @@
// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
-// RUN: not %clang_cc1 -pedantic -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXT %s
+// RUN: not %clang_cc1 -std=c99 -pedantic -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXT %s
_Noreturn int f();
int _Noreturn f(); // expected-note {{previous}}
int f _Noreturn(); // expected-error {{expected ';'}} expected-error 2{{}}
-int f() _Noreturn; // expected-error {{expected ';'}} expected-warning {{does not declare anything}} expected-error {{'_Noreturn' can only appear on functions}}
+int f() _Noreturn; // expected-error {{'_Noreturn' keyword must precede function declarator}}
_Noreturn char c1; // expected-error {{'_Noreturn' can only appear on functions}}
char _Noreturn c2; // expected-error {{'_Noreturn' can only appear on functions}}
diff --git a/test/Parser/c1x-alignas.c b/test/Parser/c1x-alignas.c
index 5b29df262d3ca..ce8436c12fbb8 100644
--- a/test/Parser/c1x-alignas.c
+++ b/test/Parser/c1x-alignas.c
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
-// RUN: not %clang_cc1 -pedantic -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXT %s
+// RUN: not %clang_cc1 -std=c99 -pedantic -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXT %s
_Alignas(4) char c1;
unsigned _Alignas(long) char c2;
diff --git a/test/Parser/colon-colon-parentheses.cpp b/test/Parser/colon-colon-parentheses.cpp
index 55948fdb0051c..e031ce2e90451 100644
--- a/test/Parser/colon-colon-parentheses.cpp
+++ b/test/Parser/colon-colon-parentheses.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify -DPR21815
// RUN: cp %s %t
// RUN: not %clang_cc1 -x c++ -fixit %t
// RUN: %clang_cc1 -x c++ %t
@@ -20,3 +20,11 @@ void foo() {
a = ::(h; // expected-error{{unexpected parenthesis after '::'}}
a = ::i;
}
+
+#ifdef PR21815
+// expected-error@+4{{C++ requires a type specifier for all declarations}}
+// expected-error@+3{{expected unqualified-id}}
+// expected-error@+3{{expected expression}}
+// expected-error@+1{{expected ';' after top level declarator}}
+a (::(
+#endif
diff --git a/test/Parser/cxx-altivec.cpp b/test/Parser/cxx-altivec.cpp
index 565decc601f81..f2ba28b641a67 100644
--- a/test/Parser/cxx-altivec.cpp
+++ b/test/Parser/cxx-altivec.cpp
@@ -61,14 +61,14 @@ vector unsigned long v_ul; // expected-warning {{Use of 'long' with '__
vector long int v_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
vector signed long int v_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
vector unsigned long int v_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector long double vv_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
-vector long double v_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+__vector long double vv_ld; // expected-error {{cannot use 'long double' with '__vector'}}
+vector long double v_ld; // expected-error {{cannot use 'long double' with '__vector'}}
// These should have errors.
-__vector double vv_d1; // expected-error {{cannot use 'double' with '__vector'}}
-vector double v_d2; // expected-error {{cannot use 'double' with '__vector'}}
-__vector long double vv_ld3; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
-vector long double v_ld4; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+__vector double vv_d1; // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on the POWER7 or later)}}
+vector double v_d2; // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on the POWER7 or later)}}
+__vector long double vv_ld3; // expected-error {{cannot use 'long double' with '__vector'}}
+vector long double v_ld4; // expected-error {{cannot use 'long double' with '__vector'}}
vector bool v_b; // expected-error {{C++ requires a type specifier for all declarations}}
vector bool float v_bf; // expected-error {{cannot use 'float' with '__vector bool'}}
vector bool double v_bd; // expected-error {{cannot use 'double' with '__vector bool'}}
@@ -78,6 +78,11 @@ vector bool unsigned int v_bsc2; // expected-error {{cannot use 'unsigned'
vector bool long v_bl; // expected-error {{cannot use 'long' with '__vector bool'}}
vector bool long long v_bll; // expected-error {{cannot use 'long long' with '__vector bool'}}
+// vector long is deprecated, but vector long long is not.
+vector long long v_ll;
+vector signed long long v_sll;
+vector unsigned long long v_ull;
+
void f() {
__vector unsigned int v = {0,0,0,0};
__vector int v__cast = (__vector int)v;
diff --git a/test/Parser/cxx-ambig-init-templ.cpp b/test/Parser/cxx-ambig-init-templ.cpp
index ac79f77e152db..1f692664137c8 100644
--- a/test/Parser/cxx-ambig-init-templ.cpp
+++ b/test/Parser/cxx-ambig-init-templ.cpp
@@ -169,3 +169,9 @@ namespace ElaboratedTypeSpecifiers {
enum E {};
};
}
+
+namespace PR20459 {
+ template <typename EncTraits> struct A {
+ void foo(int = EncTraits::template TypeEnc<int, int>::val); // ok
+ };
+}
diff --git a/test/Parser/cxx-attributes.cpp b/test/Parser/cxx-attributes.cpp
index 6fd7f4f68a465..6591532a91a20 100644
--- a/test/Parser/cxx-attributes.cpp
+++ b/test/Parser/cxx-attributes.cpp
@@ -20,3 +20,5 @@ namespace PR17666 {
typedef int __attribute__((aligned(int(1)))) T1;
typedef int __attribute__((aligned(int))) T2; // expected-error {{expected '(' for function-style cast}}
}
+
+__attribute((typename)) int x; // expected-warning {{unknown attribute 'typename' ignored}}
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp
index 80cd8288011d4..0e9a3b9d54d33 100644
--- a/test/Parser/cxx-class.cpp
+++ b/test/Parser/cxx-class.cpp
@@ -139,6 +139,54 @@ namespace CtorErrors {
};
}
+namespace DtorErrors {
+ struct A { ~A(); } a;
+ ~A::A() {} // expected-error {{'~' in destructor name should be after nested name specifier}} expected-note {{previous}}
+ A::~A() {} // expected-error {{redefinition}}
+
+ struct B { ~B(); } *b;
+ DtorErrors::~B::B() {} // expected-error {{'~' in destructor name should be after nested name specifier}}
+
+ void f() {
+ a.~A::A(); // expected-error {{'~' in destructor name should be after nested name specifier}}
+ b->~DtorErrors::~B::B(); // expected-error {{'~' in destructor name should be after nested name specifier}}
+ }
+}
+
+namespace BadFriend {
+ struct A {
+ friend int : 3; // expected-error {{friends can only be classes or functions}}
+ friend void f() = 123; // expected-error {{illegal initializer}}
+ friend virtual void f(); // expected-error {{'virtual' is invalid in friend declarations}}
+ friend void f() final; // expected-error {{'final' is invalid in friend declarations}}
+ friend void f() override; // expected-error {{'override' is invalid in friend declarations}}
+ };
+}
+
+class PR20760_a {
+ int a = ); // expected-warning {{extension}} expected-error {{expected expression}}
+ int b = }; // expected-warning {{extension}} expected-error {{expected expression}}
+ int c = ]; // expected-warning {{extension}} expected-error {{expected expression}}
+};
+class PR20760_b {
+ int d = d); // expected-warning {{extension}} expected-error {{expected ';'}}
+ int e = d]; // expected-warning {{extension}} expected-error {{expected ';'}}
+ int f = d // expected-warning {{extension}} expected-error {{expected ';'}}
+};
+
+namespace PR20887 {
+class X1 { a::operator=; }; // expected-error {{undeclared identifier 'a'}}
+class X2 { a::a; }; // expected-error {{undeclared identifier 'a'}}
+}
+
+class BadExceptionSpec {
+ void f() throw(int; // expected-error {{expected ')'}} expected-note {{to match}}
+ void g() throw( // expected-note {{to match}}
+ int( // expected-note {{to match}}
+ ; // expected-error 2{{expected ')'}} expected-error {{unexpected end of exception specification}}
+ ));
+};
+
// PR11109 must appear at the end of the source file
class pr11109r3 { // expected-note{{to match this '{'}}
public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}}
diff --git a/test/Parser/cxx-default-args.cpp b/test/Parser/cxx-default-args.cpp
index 36abf0d8cb381..0095a2f04dc41 100644
--- a/test/Parser/cxx-default-args.cpp
+++ b/test/Parser/cxx-default-args.cpp
@@ -31,3 +31,13 @@ struct T {
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);
};
+
+// rdar://18508589
+struct S {
+ void f(int &r = error); // expected-error {{use of undeclared identifier 'error'}}
+};
+
+struct U {
+ void i(int x = ) {} // expected-error{{expected expression}}
+ typedef int *fp(int x = ); // expected-error{{default arguments can only be specified for parameters in a function declaration}}
+};
diff --git a/test/Parser/cxx-member-initializers.cpp b/test/Parser/cxx-member-initializers.cpp
index ff8c880a18496..8e52adbbfd335 100644
--- a/test/Parser/cxx-member-initializers.cpp
+++ b/test/Parser/cxx-member-initializers.cpp
@@ -66,12 +66,12 @@ namespace PR16480 {
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'}}
@@ -79,3 +79,29 @@ namespace PR16480 {
Errs(X<2>) : decltype(X<0> // expected-note {{to match this '('}}
}; // expected-error {{expected ')'}}
}
+
+template <class U, class V> struct C {
+ int f() { return 4; }
+ class C1 {};
+};
+
+class D {};
+namespace N {
+struct E {
+ class F {};
+};
+}
+
+class G {
+ // These are all valid:
+ void f(int x = C<int, D>().f()) {}
+ void g(int x = C<int, ::D>().f()) {}
+ void h(int x = C<int, N::E>().f()) {}
+ void i(int x = C<int, ::N::E>().f()) {}
+ void j(int x = C<int, decltype(N::E())::F>().f()) {}
+ void k(int x = C<int, C<int, int>>().f()) {}
+ void l(int x = C<int, C<int, int>::C1>().f()) {}
+
+ // This isn't, but it shouldn't crash. The diagnostics don't matter much.
+ void m(int x = C<int, union int>().f()) {} // expected-error {{declaration of anonymous union must be a definition}} expected-error {{expected a type}}
+};
diff --git a/test/Parser/cxx-template-argument.cpp b/test/Parser/cxx-template-argument.cpp
index bbd53b2bdd691..c9cc6b8079028 100644
--- a/test/Parser/cxx-template-argument.cpp
+++ b/test/Parser/cxx-template-argument.cpp
@@ -106,3 +106,8 @@ namespace pr16225add {
{ };
}
+
+namespace PR18793 {
+ template<typename T, T> struct S {};
+ template<typename T> int g(S<T, (T())> *);
+}
diff --git a/test/Parser/cxx-template-decl.cpp b/test/Parser/cxx-template-decl.cpp
index 8b2b12037b3c6..efa42ad30d049 100644
--- a/test/Parser/cxx-template-decl.cpp
+++ b/test/Parser/cxx-template-decl.cpp
@@ -210,3 +210,31 @@ void Instantiate() {
}
}
+
+namespace func_tmpl_spec_def_in_func {
+// We failed to diagnose function template specialization definitions inside
+// functions during recovery previously.
+template <class> void FuncTemplate() {}
+void TopLevelFunc() {
+ // expected-error@+2 {{expected a qualified name after 'typename'}}
+ // expected-error@+1 {{function definition is not allowed here}}
+ typename template <> void FuncTemplate<void>() { }
+ // expected-error@+1 {{function definition is not allowed here}}
+ void NonTemplateInner() { }
+}
+}
+
+namespace broken_baseclause {
+template<typename T>
+struct base { };
+
+struct t1 : base<int,
+ public: // expected-error {{expected expression}}
+}; // expected-error {{expected class name}}
+// expected-error@-1 {{expected '{' after base class list}}
+struct t2 : base<int,
+ public // expected-error {{expected expression}}
+}; // expected-error {{expected class name}}
+// expected-error@-1 {{expected '{' after base class list}}
+
+}
diff --git a/test/Parser/cxx-variadic-func.cpp b/test/Parser/cxx-variadic-func.cpp
index b9360d6ed10a0..98a34d3e1bf67 100644
--- a/test/Parser/cxx-variadic-func.cpp
+++ b/test/Parser/cxx-variadic-func.cpp
@@ -1,5 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
void f(...) {
- int g(int(...));
+ // FIXME: There's no disambiguation here; this is unambiguous.
+ int g(int(...)); // expected-warning {{disambiguated}} expected-note {{paren}}
}
+
+void h(int n..., int m); // expected-error {{expected ')'}} expected-note {{to match}}
diff --git a/test/Parser/cxx0x-attributes.cpp b/test/Parser/cxx0x-attributes.cpp
index f8abc76fb2f3c..c68a119fc7408 100644
--- a/test/Parser/cxx0x-attributes.cpp
+++ b/test/Parser/cxx0x-attributes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat %s
// Need std::initializer_list
namespace std {
@@ -86,6 +86,10 @@ class [[]] [[]] final_class_another
[[]] [[]] alignas(16) final // expected-error {{an attribute list cannot appear here}}
[[]] [[]] alignas(16) [[]]{}; // expected-error {{an attribute list cannot appear here}}
+// The diagnostics here don't matter much, this just shouldn't crash:
+class C final [[deprecated(l]] {}); // expected-error {{use of undeclared identifier}} expected-error {{expected ']'}} expected-error {{an attribute list cannot appear here}} expected-error {{expected unqualified-id}}
+class D final alignas ([l) {}]{}); // expected-error {{expected ',' or ']' in lambda capture list}} expected-error {{an attribute list cannot appear here}}
+
[[]] struct with_init_declarators {} init_declarator;
[[]] struct no_init_declarators; // expected-error {{an attribute list cannot appear here}}
template<typename> [[]] struct no_init_declarators_template; // expected-error {{an attribute list cannot appear here}}
@@ -121,6 +125,7 @@ extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
[[]] using ns::i; // 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}}
+namespace [[]] ns2 {} // expected-warning {{attributes on a namespace declaration are incompatible with C++ standards before C++1z}}
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}}
@@ -172,7 +177,7 @@ enum [[]] E2; // expected-error {{forbids forward references}}
enum [[]] E1;
enum [[]] E3 : int;
enum [[]] {
- k_123 [[]] = 123 // expected-error {{an attribute list cannot appear here}}
+ k_123 [[]] = 123 // expected-warning {{attributes on an enumerator declaration are incompatible with C++ standards before C++1z}}
};
enum [[]] E1 e; // expected-error {{an attribute list cannot appear here}}
enum [[]] class E4 { }; // expected-error {{an attribute list cannot appear here}}
@@ -329,3 +334,10 @@ namespace {
[[deprecated()]] void foo(); // expected-error {{parentheses must be omitted if 'deprecated' attribute's argument list is empty}}
[[gnu::deprecated()]] void quux();
}
+
+namespace {
+[[ // expected-error {{expected ']'}}
+#pragma pack(pop)
+deprecated
+]] void bad();
+}
diff --git a/test/Parser/cxx0x-decl.cpp b/test/Parser/cxx0x-decl.cpp
index a0334cdde2923..994104fc9dfbb 100644
--- a/test/Parser/cxx0x-decl.cpp
+++ b/test/Parser/cxx0x-decl.cpp
@@ -116,9 +116,19 @@ namespace DuplicateSpecifier {
};
}
+namespace ColonColonDecltype {
+ struct S { struct T {}; };
+ ::decltype(S())::T invalid; // expected-error {{expected unqualified-id}}
+}
+
struct Base { virtual void f() = 0; virtual void g() = 0; virtual void h() = 0; };
struct MemberComponentOrder : Base {
void f() override __asm__("foobar") __attribute__(( )) {}
void g() __attribute__(( )) override;
void h() __attribute__(( )) override {}
};
+
+void NoMissingSemicolonHere(struct S
+ [3]);
+template<int ...N> void NoMissingSemicolonHereEither(struct S
+ ... [N]);
diff --git a/test/Parser/cxx0x-in-cxx98.cpp b/test/Parser/cxx0x-in-cxx98.cpp
index 724993811631b..10cb4d2fa53aa 100644
--- a/test/Parser/cxx0x-in-cxx98.cpp
+++ b/test/Parser/cxx0x-in-cxx98.cpp
@@ -28,3 +28,7 @@ struct Auto {
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}}
+
+struct Conv { template<typename T> operator T(); };
+bool pr21367_a = new int && false;
+bool pr21367_b = &Conv::operator int && false;
diff --git a/test/Parser/cxx0x-lambda-expressions.cpp b/test/Parser/cxx0x-lambda-expressions.cpp
index 8cfe7f3b02da0..6f69d8096e225 100644
--- a/test/Parser/cxx0x-lambda-expressions.cpp
+++ b/test/Parser/cxx0x-lambda-expressions.cpp
@@ -91,3 +91,20 @@ class C {
__attribute__((noreturn)) { while(1); }; // expected-error {{expected body of lambda expression}}
}
};
+
+template <typename>
+void PR22122() {
+ [](int) -> {}; // expected-error {{expected a type}}
+}
+
+template void PR22122<int>();
+
+struct S {
+ template <typename T>
+ void m (T x =[0); // expected-error{{expected variable name or 'this' in lambda capture list}}
+} s;
+
+struct U {
+ template <typename T>
+ void m_fn1(T x = 0[0); // expected-error{{expected ']'}} expected-note{{to match this '['}}
+} *U;
diff --git a/test/Parser/cxx11-templates.cpp b/test/Parser/cxx11-templates.cpp
new file mode 100644
index 0000000000000..ed0495281c17f
--- /dev/null
+++ b/test/Parser/cxx11-templates.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct S {
+ template <typename Ty = char>
+ static_assert(sizeof(Ty) != 1, "Not a char"); // expected-error {{a static_assert declaration cannot be a template}}
+};
+
+template <typename Ty = char>
+static_assert(sizeof(Ty) != 1, "Not a char"); // expected-error {{a static_assert declaration cannot be a template}}
+
+namespace Ellipsis {
+ template<typename ...T> void f(T t..., int n); // expected-error {{must immediately precede declared identifier}}
+ template<typename ...T> void f(int n, T t...); // expected-error {{must immediately precede declared identifier}}
+ template<typename ...T> void f(int n, T t, ...); // expected-error {{unexpanded parameter pack}}
+ template<typename ...T> void f() {
+ f([]{
+ void g(T
+ t // expected-note {{place '...' immediately before declared identifier to declare a function parameter pack}}
+ ... // expected-warning {{'...' in this location creates a C-style varargs function, not a function parameter pack}}
+ // expected-note@-1 {{insert ',' before '...' to silence this warning}}
+ );
+ void h(T (&
+ ) // expected-note {{place '...' here to declare a function parameter pack}}
+ ... // expected-warning {{'...' in this location creates a C-style varargs function, not a function parameter pack}}
+ // expected-note@-1 {{insert ',' before '...' to silence this warning}}
+ );
+ void i(T (&), ...);
+ }...);
+ }
+ template<typename ...T> struct S {
+ void f(T t...); // expected-error {{must immediately precede declared identifier}}
+ void f(T ... // expected-note {{preceding '...' declares a function parameter pack}}
+ t...); // expected-warning-re {{'...' in this location creates a C-style varargs function{{$}}}}
+ // expected-note@-1 {{insert ',' before '...' to silence this warning}}
+ };
+
+ // FIXME: We should just issue a single error in this case pointing out where
+ // the '...' goes. It's tricky to recover correctly in this case, though,
+ // because the parameter is in scope in the default argument, so must be
+ // passed to Sema before we reach the ellipsis.
+ template<typename...T> void f(T n = 1 ...);
+ // expected-warning@-1 {{creates a C-style varargs}}
+ // expected-note@-2 {{place '...' immediately before declared identifier}}
+ // expected-note@-3 {{insert ','}}
+ // expected-error@-4 {{unexpanded parameter pack}}
+}
diff --git a/test/Parser/cxx1z-attributes.cpp b/test/Parser/cxx1z-attributes.cpp
new file mode 100644
index 0000000000000..1267091ab2535
--- /dev/null
+++ b/test/Parser/cxx1z-attributes.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s
+
+namespace [[]] foo {}
+namespace [[]] {}
+namespace [[]] bad = foo; // expected-error {{attributes cannot be specified on namespace alias}}
+
+namespace [[]] A::B {} // expected-error {{attributes cannot be specified on a nested namespace definition}}
+
+enum test {
+ bing [[]],
+ bar [[]] = 1,
+ baz [[]][[]],
+ quux [[]][[]] = 4
+};
diff --git a/test/Parser/cxx1z-fold-expressions.cpp b/test/Parser/cxx1z-fold-expressions.cpp
new file mode 100644
index 0000000000000..a908311ea3160
--- /dev/null
+++ b/test/Parser/cxx1z-fold-expressions.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+template<typename ...T> constexpr auto sum(T ...t) { return (... + t); }
+template<typename ...T> constexpr auto product(T ...t) { return (t * ...); }
+template<typename ...T> constexpr auto all(T ...t) { return (true && ... && t); }
+template<typename ...T> constexpr auto all2(T ...t) { return (t && ... && true); }
+
+int k1 = (1 + ... + 2); // expected-error {{does not contain any unexpanded parameter packs}}
+int k2 = (1 + ...); // expected-error {{does not contain any unexpanded parameter packs}}
+int k3 = (... + 2); // expected-error {{does not contain any unexpanded parameter packs}}
+
+template<int ...N> void bad1() { (N + ... + N); } // expected-error {{unexpanded parameter packs in both operands}}
+// FIXME: it would be reasonable to support this as an extension.
+template<int ...N> void bad2() { (2 * N + ... + 1); } // expected-error {{expression not permitted as operand}}
+template<int ...N> void bad3() { (2 + N * ... * 1); } // expected-error {{expression not permitted as operand}}
+template<int ...N, int ...M> void bad4(int (&...x)[N]) { (N + M * ... * 1); } // expected-error {{expression not permitted as operand}}
+template<int ...N, int ...M> void fixed4(int (&...x)[N]) { ((N + M) * ... * 1); }
+
+// Parens are mandatory.
+template<int ...N> void bad5() { N + ...; } // expected-error {{expected expression}} expected-error +{{}}
+template<int ...N> void bad6() { ... + N; } // expected-error {{expected expression}}
+template<int ...N> void bad7() { N + ... + N; } // expected-error {{expected expression}} expected-error +{{}}
+
+// Must have a fold-operator in the relevant places.
+template<int ...N> int bad8() { return (N + ... * 3); } // expected-error {{operators in fold expression must be the same}}
+template<int ...N> int bad9() { return (3 + ... * N); } // expected-error {{operators in fold expression must be the same}}
+template<int ...N> int bad10() { return (3 ? ... : N); } // expected-error +{{}} expected-note {{to match}}
+template<int ...N> int bad11() { return (N + ... 0); } // expected-error {{expected a foldable binary operator}} expected-error {{expected expression}}
+template<int ...N> int bad12() { return (... N); } // expected-error {{expected expression}}
diff --git a/test/Parser/cxx1z-nested-namespace-definition.cpp b/test/Parser/cxx1z-nested-namespace-definition.cpp
new file mode 100644
index 0000000000000..96f34c540acc2
--- /dev/null
+++ b/test/Parser/cxx1z-nested-namespace-definition.cpp
@@ -0,0 +1,38 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -x c++ -fixit %t -Werror -DFIXIT
+// RUN: %clang_cc1 -x c++ %t -DFIXIT
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1z -Wc++14-compat
+
+namespace foo1::foo2::foo3 {
+#if __cplusplus <= 201400L
+// expected-warning@-2 {{nested namespace definition is a C++1z extension; define each namespace separately}}
+#else
+// expected-warning@-4 {{nested namespace definition is incompatible with C++ standards before C++1z}}
+#endif
+ int foo(int x) { return x; }
+}
+
+#ifndef FIXIT
+inline namespace goo::bar { // expected-error {{nested namespace definition cannot be 'inline'}} expected-warning 0-1{{C++11 feature}}
+ int n;
+}
+
+int m = goo::bar::n;
+#endif
+
+int foo(int x) {
+ return foo1::foo2::foo3::foo(x);
+}
+
+namespace bar1 {
+ namespace bar2 {
+ namespace bar3 {
+ int bar(int x) { return x; }
+ }
+ }
+}
+
+int bar(int x) {
+ return bar1::bar2::bar3::bar(x);
+}
diff --git a/test/Parser/debugger-import-module.m b/test/Parser/debugger-import-module.m
new file mode 100644
index 0000000000000..b6001aed6a89e
--- /dev/null
+++ b/test/Parser/debugger-import-module.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -fdebugger-support -verify %s
+// expected-no-diagnostics
+
+void importAModule() {
+ @import AModuleThatDoesntExist
+}
diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c
index 39d9dc94490df..48936d5922696 100644
--- a/test/Parser/declarators.c
+++ b/test/Parser/declarators.c
@@ -7,6 +7,7 @@ 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'}} */
+int f5(int [static]); /* expected-error {{'static' may not be used without an array size}} */
char ((((*X))));
@@ -112,6 +113,7 @@ enum E1 { e1 }: // expected-error {{expected ';'}}
struct EnumBitfield { // expected-warning {{struct without named members is a GNU extension}}
enum E2 { e2 } : 4; // ok
struct S { int n; }: // expected-error {{expected ';'}}
+ // expected-warning@-1 {{declaration does not declare anything}}
};
@@ -148,3 +150,5 @@ enum E16 {
A6; // expected-error{{expected '= constant-expression' or end of enumerator definition}}
A6a
};
+
+int PR20634 = sizeof(struct { int n; } [5]);
diff --git a/test/Parser/eof2.cpp b/test/Parser/eof2.cpp
new file mode 100644
index 0000000000000..6a8b862e60999
--- /dev/null
+++ b/test/Parser/eof2.cpp
@@ -0,0 +1,15 @@
+// RUN: not %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s
+
+// CHECK: error: expected expression
+// CHECK: error: expected member name or ';' after declaration specifiers
+// CHECK: error: expected '}'
+// CHECK: note: to match this '{'
+// CHECK: error: expected ';' after class
+// CHECK: 4 errors generated.
+
+// Do not add anything to the end of this file. This requires the whitespace
+// plus EOF after the '<' token.
+
+template <typename T>
+class a {
+ a<
diff --git a/test/Parser/ms-if-exists.c b/test/Parser/ms-if-exists.c
new file mode 100644
index 0000000000000..7dd20544a6b4d
--- /dev/null
+++ b/test/Parser/ms-if-exists.c
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
+// expected-no-diagnostics
+
+struct Type {
+};
+
+void test_if_exists_stmts() {
+ int b = 0;
+ __if_exists(Type) {
+ b++;
+ b++;
+ }
+ __if_exists(Type_not) {
+ this will not compile.
+ }
+ __if_not_exists(Type) {
+ this will not compile.
+ }
+ __if_not_exists(Type_not) {
+ b++;
+ b++;
+ }
+}
+
+int if_exists_creates_no_scope() {
+ __if_exists(Type) {
+ int x; // 'x' is declared in the parent scope.
+ }
+ __if_not_exists(Type_not) {
+ x++;
+ }
+ return x;
+}
+
+__if_exists(Type) {
+ int var23;
+}
+
+__if_exists(Type_not) {
+ this will not compile.
+}
+
+__if_not_exists(Type) {
+ this will not compile.
+}
+
+__if_not_exists(Type_not) {
+ int var244;
+}
+
+void test_if_exists_init_list() {
+
+ int array1[] = {
+ 0,
+ __if_exists(Type) {2, }
+ 3
+ };
+
+ int array2[] = {
+ 0,
+ __if_exists(Type_not) { this will not compile }
+ 3
+ };
+
+ int array3[] = {
+ 0,
+ __if_not_exists(Type_not) {2, }
+ 3
+ };
+
+ int array4[] = {
+ 0,
+ __if_not_exists(Type) { this will not compile }
+ 3
+ };
+
+}
+
+
+void test_nested_if_exists() {
+ __if_exists(Type) {
+ int x = 42;
+ __if_not_exists(Type_not) {
+ x++;
+ }
+ }
+}
diff --git a/test/Parser/ms-inline-asm.c b/test/Parser/ms-inline-asm.c
index 00508f5cf0989..72c96c3715d95 100644
--- a/test/Parser/ms-inline-asm.c
+++ b/test/Parser/ms-inline-asm.c
@@ -48,6 +48,9 @@ void t10() {
void t11() {
do { __asm mov eax, 0 __asm { __asm mov edx, 1 } } while(0);
}
+void t12() {
+ __asm jmp label // expected-error {{use of undeclared label 'label'}}
+}
int t_fail() { // expected-note {{to match this}}
__asm
- __asm { // expected-error 3 {{expected}} expected-note {{to match this}}
+ __asm { // expected-error 2 {{expected}} expected-note {{to match this}}
diff --git a/test/Parser/namespaces.cpp b/test/Parser/namespaces.cpp
index 6491cfd446b31..25ff73b8ec01d 100644
--- a/test/Parser/namespaces.cpp
+++ b/test/Parser/namespaces.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
// PR6596
namespace g { enum { o = 0 }; }
@@ -10,3 +10,7 @@ void foo() {
// PR14085
namespace PR14085 {}
namespace = PR14085; // expected-error {{expected identifier}}
+
+struct namespace_nested_in_record {
+ int k = ({namespace {}}); // expected-error {{statement expression not allowed at file scope}}
+};
diff --git a/test/Parser/nested-namespaces-recovery.cpp b/test/Parser/nested-namespaces-recovery.cpp
deleted file mode 100644
index d45938bb3e674..0000000000000
--- a/test/Parser/nested-namespaces-recovery.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: cp %s %t
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: not %clang_cc1 -x c++ -fixit %t
-// RUN: %clang_cc1 -x c++ %t
-
-namespace foo1::foo2::foo3 { // expected-error {{nested namespace definition must define each namespace separately}}
- int foo(int x) { return x; }
-}
-
-int foo(int x) {
- return foo1::foo2::foo3::foo(x);
-}
-
-namespace bar1 {
- namespace bar2 {
- namespace bar3 {
- int bar(int x) { return x; }
- }
- }
-}
-
-int bar(int x) {
- return bar1::bar2::bar3::bar(x);
-}
diff --git a/test/Parser/opencl-cl20.cl b/test/Parser/opencl-cl20.cl
new file mode 100644
index 0000000000000..b71869919ba9d
--- /dev/null
+++ b/test/Parser/opencl-cl20.cl
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -DCL20
+
+#ifdef CL20
+// expected-no-diagnostics
+#endif
+
+__generic int * __generic_test(__generic int *arg) {
+ __generic int *var;
+ return var;
+}
+#ifndef CL20
+// expected-error@-5 {{OpenCL does not support the '__generic' type qualifier}}
+// expected-error@-6 {{OpenCL does not support the '__generic' type qualifier}}
+// expected-error@-6 {{OpenCL does not support the '__generic' type qualifier}}
+#endif
+
+generic int * generic_test(generic int *arg) {
+ generic int *var;
+ return var;
+}
+#ifndef CL20
+// expected-error@-5 {{OpenCL does not support the 'generic' type qualifier}}
+// expected-error@-6 {{OpenCL does not support the 'generic' type qualifier}}
+// expected-error@-6 {{OpenCL does not support the 'generic' type qualifier}}
+#endif
diff --git a/test/Parser/pragma-loop.cpp b/test/Parser/pragma-loop.cpp
index 23f185d52284b..547d87395ef54 100644
--- a/test/Parser/pragma-loop.cpp
+++ b/test/Parser/pragma-loop.cpp
@@ -3,12 +3,85 @@
// Note that this puts the expected lines before the directives to work around
// limitations in the -verify mode.
+template <int V, int I>
+void test_nontype_template_param(int *List, int Length) {
+#pragma clang loop vectorize_width(V) interleave_count(I)
+ for (int i = 0; i < Length; i++) {
+ List[i] = i;
+ }
+
+#pragma clang loop vectorize_width(V + 4) interleave_count(I + 4)
+ for (int i = 0; i < Length; i++) {
+ List[i] = i;
+ }
+}
+
+template <int V>
+void test_nontype_template_vectorize(int *List, int Length) {
+ /* expected-error {{invalid value '-1'; must be positive}} */ #pragma clang loop vectorize_width(V)
+ for (int i = 0; i < Length; i++) {
+ List[i] = i;
+ }
+
+ /* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop vectorize_width(V / 2)
+ for (int i = 0; i < Length; i++) {
+ List[i] += i;
+ }
+}
+
+template <int I>
+void test_nontype_template_interleave(int *List, int Length) {
+ /* expected-error {{invalid value '-1'; must be positive}} */ #pragma clang loop interleave_count(I)
+ for (int i = 0; i < Length; i++) {
+ List[i] = i;
+ }
+
+ /* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop interleave_count(2 % I)
+ for (int i = 0; i < Length; i++) {
+ List[i] = i;
+ }
+}
+
+template <char V>
+void test_nontype_template_char(int *List, int Length) {
+ /* expected-error {{invalid argument of type 'char'; expected an integer type}} */ #pragma clang loop vectorize_width(V)
+ for (int i = 0; i < Length; i++) {
+ List[i] = i;
+ }
+}
+
+template <bool V>
+void test_nontype_template_bool(int *List, int Length) {
+ /* expected-error {{invalid argument of type 'bool'; expected an integer type}} */ #pragma clang loop vectorize_width(V)
+ for (int i = 0; i < Length; i++) {
+ List[i] = i;
+ }
+}
+
+template <int V, int I>
+void test_nontype_template_badarg(int *List, int Length) {
+ /* expected-error {{use of undeclared identifier 'Vec'}} */ #pragma clang loop vectorize_width(Vec) interleave_count(I)
+ /* expected-error {{use of undeclared identifier 'Int'}} */ #pragma clang loop vectorize_width(V) interleave_count(Int)
+ for (int i = 0; i < Length; i++) {
+ List[i] = i;
+ }
+}
+
+template <typename T>
+void test_type_template_vectorize(int *List, int Length) {
+ const T Value = -1;
+ /* expected-error {{invalid value '-1'; must be positive}} */ #pragma clang loop vectorize_width(Value)
+ for (int i = 0; i < Length; i++) {
+ List[i] = i;
+ }
+}
+
void test(int *List, int Length) {
int i = 0;
#pragma clang loop vectorize(enable)
#pragma clang loop interleave(enable)
-#pragma clang loop unroll(enable)
+#pragma clang loop unroll(full)
while (i + 1 < Length) {
List[i] = i;
}
@@ -43,68 +116,89 @@ void test(int *List, int Length) {
VList[j] = List[j];
}
+ test_nontype_template_param<4, 8>(List, Length);
+
/* expected-error {{expected '('}} */ #pragma clang loop vectorize
/* expected-error {{expected '('}} */ #pragma clang loop interleave
/* expected-error {{expected '('}} */ #pragma clang loop unroll
/* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable
/* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable
-/* expected-error {{expected ')'}} */ #pragma clang loop unroll(enable
+/* expected-error {{expected ')'}} */ #pragma clang loop unroll(full
/* expected-error {{expected ')'}} */ #pragma clang loop vectorize_width(4
/* expected-error {{expected ')'}} */ #pragma clang loop interleave_count(4
/* expected-error {{expected ')'}} */ #pragma clang loop unroll_count(4
-/* expected-error {{missing argument to '#pragma clang loop vectorize'; expected a positive integer value}} */ #pragma clang loop vectorize()
-/* expected-error {{missing argument to '#pragma clang loop interleave_count'; expected a positive integer value}} */ #pragma clang loop interleave_count()
-/* expected-error {{missing argument to '#pragma clang loop unroll'; expected a positive integer value}} */ #pragma clang loop unroll()
+/* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop vectorize()
+/* expected-error {{missing argument; expected an integer value}} */ #pragma clang loop interleave_count()
+/* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop unroll()
-/* expected-error {{missing option}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, or unroll_count}} */ #pragma clang loop
/* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword
/* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable)
/* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4)
/* expected-warning {{extra tokens at end of '#pragma clang loop'}} */ #pragma clang loop vectorize(enable) ,
-
while (i-4 < Length) {
List[i] = i;
}
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(0)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(0)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop vectorize_width(0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop interleave_count(0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop unroll_count(0)
+
+/* expected-error {{expression is not an integral constant expression}} expected-note {{division by zero}} */ #pragma clang loop vectorize_width(10 / 0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop interleave_count(10 / 5 - 2)
while (i-5 < Length) {
List[i] = i;
}
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(3000000000)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(3000000000)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(3000000000)
+test_nontype_template_vectorize<4>(List, Length);
+/* expected-note {{in instantiation of function template specialization}} */ test_nontype_template_vectorize<-1>(List, Length);
+test_nontype_template_interleave<8>(List, Length);
+/* expected-note {{in instantiation of function template specialization}} */ test_nontype_template_interleave<-1>(List, Length);
+
+/* expected-note {{in instantiation of function template specialization}} */ test_nontype_template_char<'A'>(List, Length); // Loop hint arg cannot be a char.
+/* expected-note {{in instantiation of function template specialization}} */ test_nontype_template_bool<true>(List, Length); // Or a bool.
+/* expected-note {{in instantiation of function template specialization}} */ test_type_template_vectorize<int>(List, Length); // Or a template type.
+
+/* expected-error {{value '3000000000' is too large}} */ #pragma clang loop vectorize_width(3000000000)
+/* expected-error {{value '3000000000' is too large}} */ #pragma clang loop interleave_count(3000000000)
+/* expected-error {{value '3000000000' is too large}} */ #pragma clang loop unroll_count(3000000000)
while (i-6 < Length) {
List[i] = i;
}
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(badvalue)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(badvalue)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(badvalue)
+/* expected-warning {{extra tokens at end of '#pragma clang loop'}} */ #pragma clang loop vectorize_width(1 +) 1
+/* expected-warning {{extra tokens at end of '#pragma clang loop'}} */ #pragma clang loop vectorize_width(1) +1
+const int VV = 4;
+/* expected-error {{expected expression}} */ #pragma clang loop vectorize_width(VV +/ 2)
+/* expected-error {{use of undeclared identifier 'undefined'}} */ #pragma clang loop vectorize_width(VV+undefined)
+/* expected-error {{expected ')'}} */ #pragma clang loop vectorize_width(1+(^*/2 * ()
+/* expected-warning {{extra tokens at end of '#pragma clang loop' - ignored}} */ #pragma clang loop vectorize_width(1+(-0[0]))))))
+
+/* expected-error {{use of undeclared identifier 'badvalue'}} */ #pragma clang loop vectorize_width(badvalue)
+/* expected-error {{use of undeclared identifier 'badvalue'}} */ #pragma clang loop interleave_count(badvalue)
+/* expected-error {{use of undeclared identifier 'badvalue'}} */ #pragma clang loop unroll_count(badvalue)
while (i-6 < Length) {
List[i] = i;
}
/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop vectorize(badidentifier)
/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop interleave(badidentifier)
-/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop unroll(badidentifier)
+/* expected-error {{invalid argument; expected 'full' or 'disable'}} */ #pragma clang loop unroll(badidentifier)
while (i-7 < Length) {
List[i] = i;
}
// PR20069 - Loop pragma arguments that are not identifiers or numeric
// constants crash FE.
-/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop vectorize(()
+/* expected-error {{expected ')'}} */ #pragma clang loop vectorize(()
/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop interleave(*)
-/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop unroll(=)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(^)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(/)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(==)
+/* expected-error {{invalid argument; expected 'full' or 'disable'}} */ #pragma clang loop unroll(=)
+/* expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}} */ #pragma clang loop vectorize_width(^)
+/* expected-error {{expected expression}} expected-error {{expected expression}} */ #pragma clang loop interleave_count(/)
+/* expected-error {{expected expression}} expected-error {{expected expression}} */ #pragma clang loop unroll_count(==)
while (i-8 < Length) {
List[i] = i;
}
@@ -136,7 +230,7 @@ void test(int *List, int Length) {
#pragma clang loop vectorize(disable)
/* expected-error {{duplicate directives 'interleave(disable)' and 'interleave(enable)'}} */ #pragma clang loop interleave(enable)
#pragma clang loop interleave(disable)
-/* expected-error {{duplicate directives 'unroll(disable)' and 'unroll(enable)'}} */ #pragma clang loop unroll(enable)
+/* expected-error {{duplicate directives 'unroll(disable)' and 'unroll(full)'}} */ #pragma clang loop unroll(full)
#pragma clang loop unroll(disable)
while (i-9 < Length) {
List[i] = i;
@@ -162,5 +256,12 @@ void test(int *List, int Length) {
List[i] = i;
}
+
+/* expected-error {{incompatible directives 'unroll(full)' and 'unroll_count(4)'}} */ #pragma clang loop unroll(full)
+#pragma clang loop unroll_count(4)
+ while (i-11 < Length) {
+ List[i] = i;
+ }
+
#pragma clang loop interleave(enable)
/* expected-error {{expected statement}} */ }
diff --git a/test/Parser/pragma-unroll.cpp b/test/Parser/pragma-unroll.cpp
index 1d89e63028c48..260945756f2f0 100644
--- a/test/Parser/pragma-unroll.cpp
+++ b/test/Parser/pragma-unroll.cpp
@@ -11,47 +11,39 @@ void test(int *List, int Length) {
List[i] = i;
}
-#pragma unroll 4
- while (i - 1 < Length) {
- List[i] = i;
- }
-
-#pragma unroll(8)
- while (i - 2 < Length) {
+#pragma nounroll
+ while (i < Length) {
List[i] = i;
}
-#pragma unroll
-#pragma unroll(8)
- while (i - 3 < Length) {
+#pragma unroll 4
+ while (i - 1 < Length) {
List[i] = i;
}
-#pragma clang loop unroll(enable)
#pragma unroll(8)
- while (i - 4 < Length) {
- List[i] = i;
- }
-
-#pragma unroll
-#pragma clang loop unroll_count(4)
- while (i - 5 < Length) {
+ while (i - 2 < Length) {
List[i] = i;
}
/* expected-error {{expected ')'}} */ #pragma unroll(4
-/* expected-error {{missing argument to '#pragma unroll'; expected a positive integer value}} */ #pragma unroll()
+/* expected-error {{missing argument; expected an integer value}} */ #pragma unroll()
/* expected-warning {{extra tokens at end of '#pragma unroll'}} */ #pragma unroll 1 2
while (i-6 < Length) {
List[i] = i;
}
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(()
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll -
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(0)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll 0
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll(3000000000)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma unroll 3000000000
+/* expected-warning {{extra tokens at end of '#pragma nounroll'}} */ #pragma nounroll 1
+ while (i-7 < Length) {
+ List[i] = i;
+ }
+
+/* expected-error {{expected ')'}} */ #pragma unroll(()
+/* expected-error {{expected expression}} */ #pragma unroll -
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll(0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll 0
+/* expected-error {{value '3000000000' is too large}} */ #pragma unroll(3000000000)
+/* expected-error {{value '3000000000' is too large}} */ #pragma unroll 3000000000
while (i-8 < Length) {
List[i] = i;
}
@@ -60,6 +52,8 @@ void test(int *List, int Length) {
/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int j = Length;
#pragma unroll 4
/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int k = Length;
+#pragma nounroll
+/* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll'}} */ int l = Length;
/* expected-error {{incompatible directives 'unroll(disable)' and '#pragma unroll(4)'}} */ #pragma unroll 4
#pragma clang loop unroll(disable)
@@ -67,14 +61,38 @@ void test(int *List, int Length) {
List[i] = i;
}
+/* expected-error {{incompatible directives 'unroll(full)' and '#pragma unroll(4)'}} */ #pragma unroll(4)
+#pragma clang loop unroll(full)
+ while (i-11 < Length) {
+ List[i] = i;
+ }
+
+/* expected-error {{incompatible directives '#pragma unroll' and '#pragma unroll(4)'}} */ #pragma unroll(4)
+#pragma unroll
+ while (i-11 < Length) {
+ List[i] = i;
+ }
+
+/* expected-error {{incompatible directives '#pragma nounroll' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4)
+#pragma nounroll
+ while (i-12 < Length) {
+ List[i] = i;
+ }
+
+/* expected-error {{duplicate directives '#pragma nounroll' and '#pragma nounroll'}} */ #pragma nounroll
+#pragma nounroll
+ while (i-13 < Length) {
+ List[i] = i;
+ }
+
/* expected-error {{duplicate directives '#pragma unroll' and '#pragma unroll'}} */ #pragma unroll
#pragma unroll
while (i-14 < Length) {
List[i] = i;
}
-/* expected-error {{duplicate directives 'unroll(enable)' and '#pragma unroll'}} */ #pragma unroll
-#pragma clang loop unroll(enable)
+/* expected-error {{duplicate directives 'unroll(full)' and '#pragma unroll'}} */ #pragma unroll
+#pragma clang loop unroll(full)
while (i-15 < Length) {
List[i] = i;
}
diff --git a/test/Parser/switch-recovery.cpp b/test/Parser/switch-recovery.cpp
index 534517018267f..4b06d55ba5944 100644
--- a/test/Parser/switch-recovery.cpp
+++ b/test/Parser/switch-recovery.cpp
@@ -220,3 +220,12 @@ bool bar0() {
case bar5: ; // expected-error{{use of undeclared identifier 'bar5'}}
}
}
+
+namespace pr21841 {
+void fn1() {
+ switch (0)
+ switch (0 // expected-note{{to match this '('}}
+ { // expected-error{{expected ')'}}
+ }
+} // expected-error{{expected statement}}
+}
diff --git a/test/Parser/vsx.c b/test/Parser/vsx.c
new file mode 100644
index 0000000000000..ead09814c8c12
--- /dev/null
+++ b/test/Parser/vsx.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -faltivec -target-feature +vsx -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -faltivec -target-feature +vsx -fsyntax-only -verify %s
+
+// Legitimate for VSX.
+__vector double vv_d1;
+vector double v_d2;
+
+// These should have errors.
+__vector long double vv_ld3; // expected-error {{cannot use 'long double' with '__vector'}}
+vector long double v_ld4; // expected-error {{cannot use 'long double' with '__vector'}}