From 6cbf37c3d58bd0dbd5f79c6b2e24b35764e6fb0a Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 9 Sep 2015 09:25:53 +0200 Subject: [PATCH] re PR c++/67504 (ICE with type dependent collapse argument) 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. From-SVN: r227579 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 4 ++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/gomp/pr67504.C | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr67504.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3a412aeef36..515a1e88a9d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-09-09 Jakub Jelinek + + PR c++/67504 + * parser.c (cp_parser_omp_clause_collapse): Test tree_fits_shwi_p + before INTEGRAL_TYPE_P test. + 2015-09-08 Jason Merrill PR c++/67041 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 67fbcda4426..d96825b08af 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -29228,8 +29228,8 @@ cp_parser_omp_clause_collapse (cp_parser *parser, tree list, location_t location 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) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 996fb61d46c..3506d4a3a40 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2015-09-09 Jakub Jelinek + PR c++/67504 + * g++.dg/gomp/pr67504.C: New test. + PR c/67501 * c-c++-common/gomp/pr67501.c: New test. diff --git a/gcc/testsuite/g++.dg/gomp/pr67504.C b/gcc/testsuite/g++.dg/gomp/pr67504.C new file mode 100644 index 00000000000..0f1758b6f14 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr67504.C @@ -0,0 +1,15 @@ +// PR c++/67504 +// { dg-do compile } +// { dg-options "-fopenmp" } + +int bar (int); +double bar (double); + +template +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++) + ; +} -- 2.30.2