summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp9
-rw-r--r--clang/test/Misc/ast-dump-decl.c2
-rw-r--r--clang/test/Misc/ast-dump-decl.cpp3
-rw-r--r--clang/test/PCH/thread-local.cpp20
-rw-r--r--clang/test/Sema/thread-specifier.c11
5 files changed, 41 insertions, 4 deletions
diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
index 59ce8b68b7c..2eaa0ba304f 100644
--- a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
+++ b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
@@ -4,16 +4,20 @@ namespace std {
typedef decltype(nullptr) nullptr_t;
}
-template<int *ip> struct IP { // expected-note 4 {{template parameter is declared here}}
+template<int *ip> struct IP { // expected-note 5 {{template parameter is declared here}}
IP<ip> *ip2;
};
+template<int &ip> struct IR {};
+
constexpr std::nullptr_t get_nullptr() { return nullptr; }
constexpr std::nullptr_t np = nullptr;
std::nullptr_t nonconst_np; // expected-note{{declared here}}
+thread_local int tl; // expected-note {{refers here}}
+
IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
IP<(0)> ip1; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
IP<nullptr> ip2;
@@ -23,6 +27,9 @@ IP<np> ip5;
IP<nonconst_np> ip5; // expected-error{{non-type template argument of type 'std::nullptr_t' (aka 'nullptr_t') is not a constant expression}} \
// expected-note{{read of non-constexpr variable 'nonconst_np' is not allowed in a constant expression}}
IP<(float*)0> ip6; // expected-error{{null non-type template argument of type 'float *' does not match template parameter of type 'int *'}}
+IP<&tl> ip7; // expected-error{{non-type template argument of type 'int *' is not a constant expression}}
+
+IR<tl> ir1; // expected-error{{non-type template argument refers to thread-local object}}
struct X { };
template<int X::*pm> struct PM { // expected-note 2 {{template parameter is declared here}}
diff --git a/clang/test/Misc/ast-dump-decl.c b/clang/test/Misc/ast-dump-decl.c
index c74da29f6d6..94335b825c8 100644
--- a/clang/test/Misc/ast-dump-decl.c
+++ b/clang/test/Misc/ast-dump-decl.c
@@ -139,7 +139,7 @@ extern int TestVarDeclSC;
// CHECK: VarDecl{{.*}} TestVarDeclSC 'int' extern
__thread int TestVarDeclThread;
-// CHECK: VarDecl{{.*}} TestVarDeclThread 'int' __thread
+// CHECK: VarDecl{{.*}} TestVarDeclThread 'int' tls{{$}}
__module_private__ int TestVarDeclPrivate;
// CHECK: VarDecl{{.*}} TestVarDeclPrivate 'int' __module_private__
diff --git a/clang/test/Misc/ast-dump-decl.cpp b/clang/test/Misc/ast-dump-decl.cpp
index c8f7d2fe6cc..b11a265a707 100644
--- a/clang/test/Misc/ast-dump-decl.cpp
+++ b/clang/test/Misc/ast-dump-decl.cpp
@@ -92,6 +92,9 @@ class TestCXXRecordDeclPack : public T... {
// CHECK-NEXT: public 'T'...
// CHECK-NEXT: CXXRecordDecl{{.*}} class TestCXXRecordDeclPack
+thread_local int TestThreadLocalInt;
+// CHECK: TestThreadLocalInt {{.*}} tls_dynamic
+
__module_private__ class TestCXXRecordDeclPrivate;
// CHECK: CXXRecordDecl{{.*}} class TestCXXRecordDeclPrivate __module_private__
diff --git a/clang/test/PCH/thread-local.cpp b/clang/test/PCH/thread-local.cpp
new file mode 100644
index 00000000000..4679946e1a8
--- /dev/null
+++ b/clang/test/PCH/thread-local.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+extern thread_local int a;
+extern _Thread_local int b;
+extern int c;
+
+#else
+
+_Thread_local int a; // expected-error {{thread-local declaration of 'a' with static initialization follows declaration with dynamic initialization}}
+// expected-note@7 {{previous declaration is here}}
+thread_local int b; // expected-error {{thread-local declaration of 'b' with dynamic initialization follows declaration with static initialization}}
+// expected-note@8 {{previous declaration is here}}
+thread_local int c; // expected-error {{thread-local declaration of 'c' follows non-thread-local declaration}}
+// expected-note@9 {{previous declaration is here}}
+
+#endif
diff --git a/clang/test/Sema/thread-specifier.c b/clang/test/Sema/thread-specifier.c
index ca6c41192b2..426a2972619 100644
--- a/clang/test/Sema/thread-specifier.c
+++ b/clang/test/Sema/thread-specifier.c
@@ -59,11 +59,18 @@ int f(__thread int t7) { // expected-error {{' is only allowed on variable decla
}
__thread typedef int t14; // expected-error-re {{cannot combine with previous '(__thread|_Thread_local|thread_local)' declaration specifier}}
-__thread int t15; // expected-note {{previous definition is here}}
+__thread int t15; // expected-note {{previous declaration is here}}
extern int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}}
-extern int t16; // expected-note {{previous definition is here}}
+extern int t16; // expected-note {{previous declaration is here}}
__thread int t16; // expected-error {{thread-local declaration of 't16' follows non-thread-local declaration}}
+#ifdef CXX11
+extern thread_local int t17; // expected-note {{previous declaration is here}}
+_Thread_local int t17; // expected-error {{thread-local declaration of 't17' with static initialization follows declaration with dynamic initialization}}
+extern _Thread_local int t18; // expected-note {{previous declaration is here}}
+thread_local int t18; // expected-error {{thread-local declaration of 't18' with dynamic initialization follows declaration with static initialization}}
+#endif
+
// PR13720
__thread int thread_int;
int *thread_int_ptr = &thread_int;
OpenPOWER on IntegriCloud