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]

[PATCH] c_parser_omp_threadprivate fixes (PR c/35438, c/35439)


Hi!

This c_parser_omp_threadprivate robustification is similar to the one added
in the C++ FE recently.

Bootstrapped/regtested on x86_64-linux, committed to trunk, will commit to
4.3 when testing finishes there.

2008-03-10  Jakub Jelinek  <jakub@redhat.com>

	PR c/35438
	PR c/35439
	* c-parser.c (c_parser_omp_threadprivate): Don't add vars with
	errorneous type.  Check that v is a VAR_DECL.

	* gcc.dg/gomp/pr35438.c: New test.
	* gcc.dg/gomp/pr35439.c: New test.

--- gcc/c-parser.c.jj	2008-02-27 09:46:58.000000000 +0100
+++ gcc/c-parser.c	2008-03-10 16:00:28.000000000 +0100
@@ -1,6 +1,7 @@
 /* Parser for C and Objective-C.
    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+   Free Software Foundation, Inc.
 
    Parser actions based on the old Bison parser; structure somewhat
    influenced by and fragments based on the C++ parser.
@@ -7964,10 +7965,14 @@ c_parser_omp_threadprivate (c_parser *pa
 
       /* If V had already been marked threadprivate, it doesn't matter
 	 whether it had been used prior to this point.  */
-      if (TREE_USED (v) && !C_DECL_THREADPRIVATE_P (v))
+      if (TREE_CODE (v) != VAR_DECL)
+	error ("%qD is not a variable", v);
+      else if (TREE_USED (v) && !C_DECL_THREADPRIVATE_P (v))
 	error ("%qE declared %<threadprivate%> after first use", v);
       else if (! TREE_STATIC (v) && ! DECL_EXTERNAL (v))
 	error ("automatic variable %qE cannot be %<threadprivate%>", v);
+      else if (TREE_TYPE (v) == error_mark_node)
+	;
       else if (! COMPLETE_TYPE_P (TREE_TYPE (v)))
 	error ("%<threadprivate%> %qE has incomplete type", v);
       else
--- gcc/testsuite/gcc.dg/gomp/pr35438.c.jj	2008-03-10 16:03:55.000000000 +0100
+++ gcc/testsuite/gcc.dg/gomp/pr35438.c	2008-03-10 16:03:32.000000000 +0100
@@ -0,0 +1,6 @@
+/* PR c/35438 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void foo ();
+#pragma omp threadprivate(foo)	/* { dg-error "is not a variable" } */
--- gcc/testsuite/gcc.dg/gomp/pr35439.c.jj	2008-03-10 15:52:21.000000000 +0100
+++ gcc/testsuite/gcc.dg/gomp/pr35439.c	2008-03-10 15:51:48.000000000 +0100
@@ -0,0 +1,6 @@
+/* PR c/35439 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void x[1];	/* { dg-error "array of voids" } */
+#pragma omp threadprivate(x)


	Jakub


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