From 92fc0178c61db0fa9a9f52b4873fa366e47f658c Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 30 Apr 2014 17:10:18 +0000 Subject: __thread: Move constant init check to CheckCompleteVariableDeclaration We were emitting dynamic initializers for __thread variables if there was no explicit initializer, as in this test case: struct S { S(); }; __thread S s; llvm-svn: 207675 --- clang/test/Sema/thread-specifier.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'clang/test') diff --git a/clang/test/Sema/thread-specifier.c b/clang/test/Sema/thread-specifier.c index 39243d1a760..d49b350667a 100644 --- a/clang/test/Sema/thread-specifier.c +++ b/clang/test/Sema/thread-specifier.c @@ -107,4 +107,17 @@ __thread S s; #endif #endif +#ifdef __cplusplus +struct HasCtor { + HasCtor(); +}; +__thread HasCtor var_with_ctor; +#if !defined(CXX11) +// expected-error@-2 {{initializer for thread-local variable must be a constant expression}} +#if __cplusplus >= 201103L +// expected-note@-4 {{use 'thread_local' to allow this}} +#endif +#endif +#endif + __thread int aggregate[10] = {0}; -- cgit v1.2.3