re PR c++/34964 (ICE with broken variable in #pragma omp threadprivate)

PR c++/34964
	PR c++/35244
	* semantics.c (finish_omp_threadprivate): Do nothing for error_operand_p
	vars.  Afterwards ensure v is VAR_DECL.

	* gcc.dg/gomp/pr34964.c: New test.
	* g++.dg/gomp/pr34964.C: New test.
	* gcc.dg/gomp/pr35244.c: New test.
	* g++.dg/gomp/pr35244.C: New test.

From-SVN: r132425
This commit is contained in:
Jakub Jelinek 2008-02-19 11:16:29 +01:00 committed by Jakub Jelinek
parent dadb19e068
commit edb6000e37
7 changed files with 80 additions and 1 deletions

View File

@ -1,5 +1,10 @@
2008-02-19 Jakub Jelinek <jakub@redhat.com>
PR c++/34964
PR c++/35244
* semantics.c (finish_omp_threadprivate): Do nothing for error_operand_p
vars. Afterwards ensure v is VAR_DECL.
PR c++/35078
* parser.c (cp_parser_omp_for_loop): If DECL has REFERENCE_TYPE, don't
call cp_finish_decl.

View File

@ -3742,9 +3742,14 @@ finish_omp_threadprivate (tree vars)
{
tree v = TREE_PURPOSE (t);
if (error_operand_p (v))
;
else if (TREE_CODE (v) != VAR_DECL)
error ("%<threadprivate%> %qD is not file, namespace "
"or block scope variable", v);
/* If V had already been marked threadprivate, it doesn't matter
whether it had been used prior to this point. */
if (TREE_USED (v)
else if (TREE_USED (v)
&& (DECL_LANG_SPECIFIC (v) == NULL
|| !CP_DECL_THREADPRIVATE_P (v)))
error ("%qE declared %<threadprivate%> after first use", v);

View File

@ -1,5 +1,12 @@
2008-02-19 Jakub Jelinek <jakub@redhat.com>
PR c++/34964
PR c++/35244
* gcc.dg/gomp/pr34964.c: New test.
* g++.dg/gomp/pr34964.C: New test.
* gcc.dg/gomp/pr35244.c: New test.
* g++.dg/gomp/pr35244.C: New test.
PR c++/35078
* g++.dg/gomp/pr35078.C: New test.

View File

@ -0,0 +1,6 @@
// PR c++/34964
// { dg-do compile }
// { dg-options "-fopenmp" }
char x[] = 0; // { dg-error "initializer fails to determine size" }
#pragma omp threadprivate (x)

View File

@ -0,0 +1,30 @@
// PR c++/35244
// { dg-do compile }
// { dg-require-effective-target tls_native }
// { dg-options "-fopenmp" }
int v1;
namespace N1
{
int v2;
}
namespace N2
{
int v3;
}
using N1::v2;
using namespace N2;
struct A;
typedef int i;
#pragma omp threadprivate (i) // { dg-error "is not file, namespace or block scope variable" }
#pragma omp threadprivate (A) // { dg-error "is not file, namespace or block scope variable" }
#pragma omp threadprivate (v1, v2, v3)
void foo ()
{
static int v4;
{
static int v5;
#pragma omp threadprivate (v4, v5)
}
}

View File

@ -0,0 +1,6 @@
/* PR c++/34964 */
/* { dg-do compile } */
/* { dg-options "-fopenmp" } */
char x[] = 0; /* { dg-error "invalid initializer" } */
#pragma omp threadprivate (x)

View File

@ -0,0 +1,20 @@
/* PR c++/35244 */
/* { dg-do compile } */
/* { dg-require-effective-target tls_native } */
/* { dg-options "-fopenmp" } */
int v1;
typedef struct A A;
typedef int i;
#pragma omp threadprivate (i) /* { dg-error "expected identifier before" } */
#pragma omp threadprivate (A) /* { dg-error "expected identifier before" } */
#pragma omp threadprivate (v1)
void foo ()
{
static int v4;
{
static int v5;
#pragma omp threadprivate (v4, v5)
}
}