re PR c++/48632 (Internal compiler error when using OpenMP with template)
authorJakub Jelinek <jakub@redhat.com>
Mon, 18 Apr 2011 21:55:07 +0000 (23:55 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 18 Apr 2011 21:55:07 +0000 (23:55 +0200)
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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr48632.C [new file with mode: 0644]

index 672485e44aa7bef84771c73602fc309448cd5e3a..e7d75e881fe30287396d26f2064057f2f6c0fb1e 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-18  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <meyering@redhat.com>
 
        * pt.c (type_unification_real): Fix typo in comment: s/in in/in/.
index 2c7ace6bbb965c310e33e2ece9b60741d154a492..7d3121c1b57950f61efb1cb0a1d69b555651bf63 100644 (file)
@@ -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
index 5295ec5809f72a70dd8b695a7493608832575244..7f1ff5872e4bd8946ecfbef0f39686b383bf4f04 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/48632
+       * g++.dg/gomp/pr48632.C: New test.
+
 2011-04-18  Uros Bizjak  <ubizjak@gmail.com>
 
        * 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 (file)
index 0000000..afa8b18
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/48632
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template<typename T>
+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);
+}