Hi! On invalid code, apparently a few spots in the clause handling could call type_dependent_expression_p on a TYPE_DECL, which then fails assertion. This arranges for it to be called only on the VAR/PARM_DECLs.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk and 5 branch. 2015-09-10 Jakub Jelinek <ja...@redhat.com> PR c++/67522 * semantics.c (handle_omp_array_sections_1): Only run type_dependent_expression_p on VAR_DECL/PARM_DECLs. (finish_omp_clauses) <case OMP_CLAUSE_LINEAR>: 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. --- gcc/cp/semantics.c.jj 2015-09-09 17:45:32.757525754 +0200 +++ gcc/cp/semantics.c 2015-09-09 17:37:31.056607387 +0200 @@ -4294,8 +4294,6 @@ handle_omp_array_sections_1 (tree c, tre { 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, tre 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); --- gcc/testsuite/g++.dg/gomp/pr67522.C.jj 2015-09-09 17:46:51.402370281 +0200 +++ gcc/testsuite/g++.dg/gomp/pr67522.C 2015-09-09 17:44:26.000000000 +0200 @@ -0,0 +1,26 @@ +// PR c++/67522 +// { dg-do compile } +// { dg-options "-fopenmp" } + +struct S; + +template <int N> +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> (); +} Jakub