From 37a8ccfcdcfe73378717101f82767760ae35f5a5 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 18 Apr 2011 23:55:07 +0200 Subject: [PATCH] re PR c++/48632 (Internal compiler error when using OpenMP with template) PR c++/48632 * parser.c (cp_parser_omp_for_loop): Don't use cp_parser_omp_for_incr for type dependent pointers. * g++.dg/gomp/pr48632.C: New test. From-SVN: r172674 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/gomp/pr48632.C | 22 ++++++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr48632.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 672485e44aa..e7d75e881fe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-04-18 Jakub Jelinek + + PR c++/48632 + * parser.c (cp_parser_omp_for_loop): Don't use cp_parser_omp_for_incr + for type dependent pointers. + 2011-04-18 Jim Meyering * pt.c (type_unification_real): Fix typo in comment: s/in in/in/. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 2c7ace6bbb9..7d3121c1b57 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -24496,7 +24496,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) /* If decl is an iterator, preserve the operator on decl until finish_omp_for. */ if (decl - && (type_dependent_expression_p (decl) + && ((type_dependent_expression_p (decl) + && !POINTER_TYPE_P (TREE_TYPE (decl))) || CLASS_TYPE_P (TREE_TYPE (decl)))) incr = cp_parser_omp_for_incr (parser, decl); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5295ec5809f..7f1ff5872e4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-04-18 Jakub Jelinek + + PR c++/48632 + * g++.dg/gomp/pr48632.C: New test. + 2011-04-18 Uros Bizjak * gcc.target/i386/sse2-maskmovdqu.c: New test. diff --git a/gcc/testsuite/g++.dg/gomp/pr48632.C b/gcc/testsuite/g++.dg/gomp/pr48632.C new file mode 100644 index 00000000000..afa8b189336 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr48632.C @@ -0,0 +1,22 @@ +// PR c++/48632 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template +void +foo (T *x, T *y, unsigned z) +{ +#pragma omp parallel for + for (T *p = x; p < y; p += z) + ; +#pragma omp parallel for + for (T *p = y; p > x; p -= z) + ; +} + +int +main () +{ + char buf[10]; + foo (&buf[0], &buf[9], 1); +} -- 2.30.2