Hi! The following patch removes errorneous reduction clause already during parsing, so that we don't ICE on it during instantiation.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2018-03-30 Jakub Jelinek <ja...@redhat.com> PR c++/84791 * semantics.c (finish_omp_reduction_clause): If OMP_CLAUSE_REDUCTION_PLACEHOLDER is error_mark_node, return true even if processing_template_decl. * g++.dg/gomp/pr84791.C: New test. --- gcc/cp/semantics.c.jj 2018-03-23 21:33:56.279959167 +0100 +++ gcc/cp/semantics.c 2018-03-29 14:42:05.759995585 +0200 @@ -5623,7 +5623,11 @@ finish_omp_reduction_clause (tree c, boo return false; } else if (processing_template_decl) - return false; + { + if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == error_mark_node) + return true; + return false; + } tree id = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c); --- gcc/testsuite/g++.dg/gomp/pr84791.C.jj 2018-03-29 14:35:04.377774216 +0200 +++ gcc/testsuite/g++.dg/gomp/pr84791.C 2018-03-29 14:37:17.491839303 +0200 @@ -0,0 +1,15 @@ +// PR c++/84791 +// { dg-do compile } + +typedef int I; + +template <int> +void +foo () +{ + I i; + #pragma omp parallel reduction (I::I: i) // { dg-error "'I' is not a class, namespace, or enumeration" "" { target c++11 } } + ; // { dg-error "'I' is not a class or namespace" "" { target c++98_only } .-1 } +} + +template void foo<0> (); Jakub