Hi! The following testcase ICEs because the collapse argument is type dependent and has NULL TREE_TYPE, so testing INTEGRAL_TYPE_P on it ICEs. I hope all INTEGER_CSTs have non-NULL type and thus just swapping the conditions is enough, if not, I could add !type_dependent_expression_p (num) test.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk and 5 branch. 2015-09-09 Jakub Jelinek <ja...@redhat.com> PR c++/67504 * parser.c (cp_parser_omp_clause_collapse): Test tree_fits_shwi_p before INTEGRAL_TYPE_P test. * g++.dg/gomp/pr67504.C: New test. --- gcc/cp/parser.c.jj 2015-08-24 18:27:13.000000000 +0200 +++ gcc/cp/parser.c 2015-09-08 18:13:30.966099538 +0200 @@ -29228,8 +29228,8 @@ cp_parser_omp_clause_collapse (cp_parser if (num == error_mark_node) return list; num = fold_non_dependent_expr (num); - if (!INTEGRAL_TYPE_P (TREE_TYPE (num)) - || !tree_fits_shwi_p (num) + if (!tree_fits_shwi_p (num) + || !INTEGRAL_TYPE_P (TREE_TYPE (num)) || (n = tree_to_shwi (num)) <= 0 || (int) n != n) { --- gcc/testsuite/g++.dg/gomp/pr67504.C.jj 2015-09-08 18:29:30.788946041 +0200 +++ gcc/testsuite/g++.dg/gomp/pr67504.C 2015-09-08 18:32:22.351405950 +0200 @@ -0,0 +1,15 @@ +// PR c++/67504 +// { dg-do compile } +// { dg-options "-fopenmp" } + +int bar (int); +double bar (double); + +template <typename T> +void +foo (T x) +{ + #pragma omp for collapse (x + 1) // { dg-error "collapse argument needs positive constant integer expression" } + for (int i = 0; i < 10; i++) + ; +} Jakub