]> granicus.if.org Git - clang/commitdiff
Print an error for uses of __thread on targets which don't support it.
authorEli Friedman <eli.friedman@gmail.com>
Sun, 19 Apr 2009 21:48:33 +0000 (21:48 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 19 Apr 2009 21:48:33 +0000 (21:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69553 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDecl.cpp
test/CodeGen/thread-specifier.c
test/Sema/thread-specifier.c

index 1c2b0e915c28ee2972c1d3f558c3eb5895405125..b2f14633bf713aa8aafccf9135f5f3abf261d462 100644 (file)
@@ -97,6 +97,8 @@ def err_invalid_thread : Error<
   "'__thread' is only allowed on variable declarations">;
 def err_thread_non_global : Error<
   "'__thread' variables must have global storage">;
+def err_thread_unsupported : Error<
+  "thread-local storage is unsupported for the current target">;
 
 /// Built-in functions.
 def ext_implicit_lib_function_decl : ExtWarn<
index 90df45a5b27869aa2ca8e4ac323c135c122bbb17..64fcddd92d0a9c907a0a996b4149ba85228beed3 100644 (file)
@@ -1734,6 +1734,8 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
   if (D.getDeclSpec().isThreadSpecified()) {
     if (NewVD->hasLocalStorage())
       Diag(D.getDeclSpec().getThreadSpecLoc(), diag::err_thread_non_global);
+    else if (!Context.Target.isTLSSupported())
+      Diag(D.getDeclSpec().getThreadSpecLoc(), diag::err_thread_unsupported);
     else
       NewVD->setThreadSpecified(true);
   }
index 08992a6e229191b732822f5db0313c19162c9f3b..456f7a6d9761e49562be4e149c08728b7cf4eece 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: clang-cc -emit-llvm -o - %s | grep thread_local | count 4
+// RUN: clang-cc -triple i686-pc-linux-gnu -emit-llvm -o - %s | grep thread_local | count 4
 
 __thread int a;
 extern __thread int b;
index 1d711c1b27bb72b5736cd07de176656263af75e8..8d66e539c875d90a06db0ec315bfd09599a7cead 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify %s
+// RUN: clang-cc -triple i686-pc-linux-gnu -fsyntax-only -verify %s
 
 __thread int t1;
 __thread extern int t2;