re PR c++/33372 (segfault on incomplete code in openmp mode)

PR c++/33372
	* semantics.c (finish_omp_clauses): Check !type_dependent_expression_p
	before checking if its type is integral.

	* g++.dg/gomp/pr33372-1.C: New test.
	* g++.dg/gomp/pr33372-2.C: New test.
	* g++.dg/gomp/pr33372-3.C: New test.

From-SVN: r129555
This commit is contained in:
Jakub Jelinek 2007-10-22 21:11:36 +02:00 committed by Jakub Jelinek
parent 5818c8e436
commit 6e684eee8d
6 changed files with 74 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2007-10-22 Jakub Jelinek <jakub@redhat.com>
PR c++/33372
* semantics.c (finish_omp_clauses): Check !type_dependent_expression_p
before checking if its type is integral.
2007-10-22 Jason Merrill <jason@redhat.com>
PR c++/33620

View File

@ -3413,8 +3413,8 @@ finish_omp_clauses (tree clauses)
t = OMP_CLAUSE_NUM_THREADS_EXPR (c);
if (t == error_mark_node)
remove = true;
else if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
&& !type_dependent_expression_p (t))
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
error ("num_threads expression must be integral");
remove = true;
@ -3427,8 +3427,8 @@ finish_omp_clauses (tree clauses)
;
else if (t == error_mark_node)
remove = true;
else if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
&& !type_dependent_expression_p (t))
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
error ("schedule chunk size expression must be integral");
remove = true;

View File

@ -1,3 +1,10 @@
2007-10-22 Jakub Jelinek <jakub@redhat.com>
PR c++/33372
* g++.dg/gomp/pr33372-1.C: New test.
* g++.dg/gomp/pr33372-2.C: New test.
* g++.dg/gomp/pr33372-3.C: New test.
2007-10-22 Michael Matz <matz@suse.de>
PR tree-optimization/33855

View File

@ -0,0 +1,19 @@
// PR c++/33372
// { dg-do compile }
// { dg-options "-fopenmp" }
template <typename T>
void f ()
{
extern T n ();
#pragma omp parallel num_threads(n) // { dg-error "num_threads expression must be integral" }
;
#pragma omp parallel for schedule(static, n)
for (int i = 0; i < 10; i++) // { dg-error "chunk size expression must be integral" }
;
}
void g ()
{
f<int> ();
}

View File

@ -0,0 +1,19 @@
// PR c++/33372
// { dg-do compile }
// { dg-options "-fopenmp" }
template <typename T>
void f ()
{
T n = 6;
#pragma omp parallel num_threads(n)
;
#pragma omp parallel for schedule(static, n)
for (int i = 0; i < 10; i++)
;
}
void g ()
{
f<int> ();
}

View File

@ -0,0 +1,19 @@
// PR c++/33372
// { dg-do compile }
// { dg-options "-fopenmp" }
template <typename T>
void f ()
{
T n = 6;
#pragma omp parallel num_threads(n) // { dg-error "num_threads expression must be integral" }
;
#pragma omp parallel for schedule(static, n)
for (int i = 0; i < 10; i++) // { dg-error "chunk size expression must be integral" }
;
}
void g ()
{
f<double> ();
}