This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gomp] fix threadprivate


I broke it with one of my previous patches.  Missed because we didn't
have a testcase for it.


r~


        * c-parser.c: Include rtl.h.
        (c_parser_pragma_omp_threadprivate): Update for TREE_PURPOSE change.
        Diagnose threadprivate after first use.
        * Makefile.in (c-parser.o): Add RTL_H.

        * gcc.dg/gomp/tls-1.c: New.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1501.4.13
diff -u -p -r1.1501.4.13 Makefile.in
--- Makefile.in	26 Sep 2005 20:55:34 -0000	1.1501.4.13
+++ Makefile.in	28 Sep 2005 06:44:42 -0000
@@ -1459,7 +1459,7 @@ c-errors.o: c-errors.c $(CONFIG_H) $(SYS
 c-parser.o : c-parser.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     $(GGC_H) $(TIMEVAR_H) $(C_TREE_H) input.h $(FLAGS_H) toplev.h output.h \
     $(CPPLIB_H) gt-c-parser.h langhooks.h $(C_COMMON_H) $(C_PRAGMA_H) \
-    vec.h
+    vec.h $(RTL_H)
 
 srcextra: gcc.srcextra lang.srcextra
 
Index: c-parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-parser.c,v
retrieving revision 2.17.4.24
diff -u -p -r2.17.4.24 c-parser.c
--- c-parser.c	27 Sep 2005 23:35:30 -0000	2.17.4.24
+++ c-parser.c	28 Sep 2005 06:44:42 -0000
@@ -42,6 +42,7 @@ Software Foundation, 51 Franklin Street,
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "rtl.h"
 #include "langhooks.h"
 #include "input.h"
 #include "cpplib.h"
@@ -7794,16 +7795,20 @@ c_parser_pragma_omp_threadprivate (cpp_r
 {
   if (c_parser_require (the_parser, CPP_OPEN_PAREN, "expected %<(%>"))
     {
-      extern enum tls_model decl_default_tls_model (tree);
-      tree t;
-      tree vars = c_parser_pragma_omp_variable_list (the_parser);
+      tree vars, t;
+
+      vars = c_parser_pragma_omp_variable_list (the_parser);
       c_parser_skip_until_found (the_parser, CPP_CLOSE_PAREN, "expected %<)%>");
 
       /* Mark every variable in VARS to be assigned thread local storage.  */
       for (t = vars; t; t = TREE_CHAIN (t))
 	{
-	  tree v = TREE_VALUE (t);
-	  DECL_TLS_MODEL (v) = decl_default_tls_model (v);
+	  tree v = TREE_PURPOSE (t);
+
+	  if (TREE_USED (v))
+	    error ("%qE declared %<threadprivate%> after first use", v);
+	  else
+	    DECL_TLS_MODEL (v) = decl_default_tls_model (v);
 	}
     }
 
Index: testsuite/gcc.dg/gomp/tls-1.c
===================================================================
RCS file: testsuite/gcc.dg/gomp/tls-1.c
diff -N testsuite/gcc.dg/gomp/tls-1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/gomp/tls-1.c	28 Sep 2005 06:44:43 -0000
@@ -0,0 +1,17 @@
+// { dg-do compile }
+
+int tp1;
+static int tp2;
+extern int tp3;
+
+int tp4 = 1;
+static int tp5 = 1;
+
+#pragma omp threadprivate (tp1, tp2, tp3, tp4, tp5)
+
+#pragma omp threadprivate (undef)	// { dg-error "undeclared" }
+
+int tp6;
+int foo(void) { return tp6; }
+
+#pragma omp threadprivate (tp6)		// { dg-error "after first use" }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]