[cfe-commits] r69553 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/CodeGen/thread-specifier.c test/Sema/thread-specifier.c

Eli Friedman eli.friedman at gmail.com
Sun Apr 19 14:48:33 PDT 2009


Author: efriedma
Date: Sun Apr 19 16:48:33 2009
New Revision: 69553

URL: http://llvm.org/viewvc/llvm-project?rev=69553&view=rev
Log:
Print an error for uses of __thread on targets which don't support it.


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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=69553&r1=69552&r2=69553&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Apr 19 16:48:33 2009
@@ -97,6 +97,8 @@
   "'__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<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=69553&r1=69552&r2=69553&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Apr 19 16:48:33 2009
@@ -1734,6 +1734,8 @@
   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);
   }

Modified: cfe/trunk/test/CodeGen/thread-specifier.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thread-specifier.c?rev=69553&r1=69552&r2=69553&view=diff

==============================================================================
--- cfe/trunk/test/CodeGen/thread-specifier.c (original)
+++ cfe/trunk/test/CodeGen/thread-specifier.c Sun Apr 19 16:48:33 2009
@@ -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;

Modified: cfe/trunk/test/Sema/thread-specifier.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/thread-specifier.c?rev=69553&r1=69552&r2=69553&view=diff

==============================================================================
--- cfe/trunk/test/Sema/thread-specifier.c (original)
+++ cfe/trunk/test/Sema/thread-specifier.c Sun Apr 19 16:48:33 2009
@@ -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;





More information about the cfe-commits mailing list