From 5df27e4a3eceb7ec1a69108e5be6cc918dee846b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 10 Mar 2008 20:40:39 +0100 Subject: [PATCH] re PR c/35438 (ICE with invalid use of threadprivate) 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. From-SVN: r133085 --- gcc/ChangeLog | 5 +++++ gcc/c-parser.c | 9 +++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/gomp/pr35438.c | 6 ++++++ gcc/testsuite/gcc.dg/gomp/pr35439.c | 6 ++++++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/gomp/pr35438.c create mode 100644 gcc/testsuite/gcc.dg/gomp/pr35439.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f6d48e7f494..5e06cc3154a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2008-03-10 Jakub Jelinek + 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. diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 1e63c14ef8b..831f95ac1e2 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -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 % after first use", v); else if (! TREE_STATIC (v) && ! DECL_EXTERNAL (v)) error ("automatic variable %qE cannot be %", v); + else if (TREE_TYPE (v) == error_mark_node) + ; else if (! COMPLETE_TYPE_P (TREE_TYPE (v))) error ("% %qE has incomplete type", v); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5cefdef4011..1427ceaae92 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2008-03-10 Jakub Jelinek + 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 index 00000000000..a3ae7de0b6a --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr35438.c @@ -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 index 00000000000..1669a97a08f --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr35439.c @@ -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) -- 2.30.2