From 7da8534d1e1ec7b1470ea556b1444c5173799348 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 10 Sep 2015 09:34:42 +0200 Subject: [PATCH] re PR c++/67522 (OpenMP ICE in type_dependent_expression_p) PR c++/67522 * semantics.c (handle_omp_array_sections_1): Only run type_dependent_expression_p on VAR_DECL/PARM_DECLs. (finish_omp_clauses) : Likewise. Don't adjust OMP_CLAUSE_LINEAR_STEP if OMP_CLAUSE_DECL is not a VAR_DECL/PARM_DECL. * g++.dg/gomp/pr67522.C: New test. From-SVN: r227610 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/semantics.c | 11 +++++++---- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/gomp/pr67522.C | 26 ++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr67522.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4b32f5ae383..32646e0a1ba 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,12 @@ 2015-09-10 Jakub Jelinek + PR c++/67522 + * semantics.c (handle_omp_array_sections_1): Only run + type_dependent_expression_p on VAR_DECL/PARM_DECLs. + (finish_omp_clauses) : Likewise. + Don't adjust OMP_CLAUSE_LINEAR_STEP if OMP_CLAUSE_DECL + is not a VAR_DECL/PARM_DECL. + PR c++/67511 * semantics.c (handle_omp_for_class_iterator): Don't wrap error_mark_node into a NOP_EXPR to void_type_node. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5c3f1bea808..0897ff70d4b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4294,8 +4294,6 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, { if (error_operand_p (t)) return error_mark_node; - if (type_dependent_expression_p (t)) - return NULL_TREE; if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL) { if (processing_template_decl) @@ -4318,6 +4316,8 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); return error_mark_node; } + if (type_dependent_expression_p (t)) + return NULL_TREE; t = convert_from_reference (t); return t; } @@ -5332,7 +5332,8 @@ finish_omp_clauses (tree clauses) goto check_dup_generic; case OMP_CLAUSE_LINEAR: t = OMP_CLAUSE_DECL (c); - if (!type_dependent_expression_p (t) + if ((VAR_P (t) || TREE_CODE (t) == PARM_DECL) + && !type_dependent_expression_p (t) && !INTEGRAL_TYPE_P (TREE_TYPE (t)) && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE) { @@ -5359,7 +5360,9 @@ finish_omp_clauses (tree clauses) else { t = mark_rvalue_use (t); - if (!processing_template_decl) + if (!processing_template_decl + && (VAR_P (OMP_CLAUSE_DECL (c)) + || TREE_CODE (OMP_CLAUSE_DECL (c)) == PARM_DECL)) { if (TREE_CODE (OMP_CLAUSE_DECL (c)) == PARM_DECL) t = maybe_constant_value (t); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e055c442c44..d1d4cd4671a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2015-09-10 Jakub Jelinek + PR c++/67522 + * g++.dg/gomp/pr67522.C: New test. + PR middle-end/67521 * c-c++-common/gomp/pr67521.c: New test. diff --git a/gcc/testsuite/g++.dg/gomp/pr67522.C b/gcc/testsuite/g++.dg/gomp/pr67522.C new file mode 100644 index 00000000000..84c854afd92 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr67522.C @@ -0,0 +1,26 @@ +// PR c++/67522 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct S; + +template +void +foo (void) +{ + #pragma omp simd linear (S) // { dg-error "is not a variable in clause" } + for (int i = 0; i < 16; i++) + ; + + #pragma omp target map (S[0:10]) // { dg-error "is not a variable in" } + ; + + #pragma omp task depend (inout: S[0:10]) // { dg-error "is not a variable in" } + ; +} + +void +bar () +{ + foo <0> (); +} -- 2.30.2