PR c/35438
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Mar 2008 19:40:39 +0000 (19:40 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Mar 2008 19:40:39 +0000 (19:40 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133085 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gomp/pr35438.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gomp/pr35439.c [new file with mode: 0644]

index f6d48e7..5e06cc3 100644 (file)
@@ -1,5 +1,10 @@
 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.
+
        PR middle-end/35099
        * tree-cfg.c (new_label_mapper): Update cfun->last_label_uid.
 
index 1e63c14..831f95a 100644 (file)
@@ -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 *parser)
 
       /* 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
index 5cefdef..1427cea 100644 (file)
@@ -1,5 +1,10 @@
 2008-03-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/35438
+       PR c/35439
+       * gcc.dg/gomp/pr35438.c: New test.
+       * gcc.dg/gomp/pr35439.c: New test.
+
        PR middle-end/35099
        * g++.dg/gomp/pr35099.C: New test.
 
diff --git a/gcc/testsuite/gcc.dg/gomp/pr35438.c b/gcc/testsuite/gcc.dg/gomp/pr35438.c
new file mode 100644 (file)
index 0000000..a3ae7de
--- /dev/null
@@ -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" } */
diff --git a/gcc/testsuite/gcc.dg/gomp/pr35439.c b/gcc/testsuite/gcc.dg/gomp/pr35439.c
new file mode 100644 (file)
index 0000000..1669a97
--- /dev/null
@@ -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)