PR c++/37533
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Sep 2008 18:57:18 +0000 (18:57 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Sep 2008 18:57:18 +0000 (18:57 +0000)
* semantics.c (finish_omp_for): If processing_template_decl, just build
MODIFY_EXPR for init instead of calling cp_build_modify_expr.

* g++.dg/gomp/pr37533.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140613 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr37533.C [new file with mode: 0644]

index 4b5105e..dc525c2 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/37533
+       * semantics.c (finish_omp_for): If processing_template_decl, just build
+       MODIFY_EXPR for init instead of calling cp_build_modify_expr.
+
 2008-09-23  Aldy Hernandez  <aldyh@redhat.com>
 
        * typeck.c (build_array_ref): Pass location to cp_build_binary_op.
index 82a0495..10c89d8 100644 (file)
@@ -4291,8 +4291,12 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
        }
 
       if (!processing_template_decl)
-       init = fold_build_cleanup_point_expr (TREE_TYPE (init), init);
-      init = cp_build_modify_expr (decl, NOP_EXPR, init, tf_warning_or_error);
+       {
+         init = fold_build_cleanup_point_expr (TREE_TYPE (init), init);
+         init = cp_build_modify_expr (decl, NOP_EXPR, init, tf_warning_or_error);
+       }
+      else
+       init = build2 (MODIFY_EXPR, void_type_node, decl, init);
       if (cond && TREE_SIDE_EFFECTS (cond) && COMPARISON_CLASS_P (cond))
        {
          int n = TREE_SIDE_EFFECTS (TREE_OPERAND (cond, 1)) != 0;
index 73b6981..c93187e 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/37533
+       * g++.dg/gomp/pr37533.C: New test.
+
 2008-09-23  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.dg/vect/slp-widen-mult-s16.c: Fix typo.
diff --git a/gcc/testsuite/g++.dg/gomp/pr37533.C b/gcc/testsuite/g++.dg/gomp/pr37533.C
new file mode 100644 (file)
index 0000000..7bf6194
--- /dev/null
@@ -0,0 +1,50 @@
+// PR c++/37533
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template<int>
+void
+f1 ()
+{
+#pragma omp parallel for
+  for (int i = ""; i < 4; ++i) // { dg-error "invalid conversion from" }
+    ;
+}
+
+template<int>
+void
+f2 ()
+{
+  int i;
+#pragma omp parallel for
+  for (i = ""; i < 4; ++i)     // { dg-error "invalid conversion from" }
+    ;
+}
+
+template<typename T>
+void
+f3 ()
+{
+#pragma omp parallel for
+  for (T i = ""; i < 4; ++i)   // { dg-error "invalid conversion from" }
+    ;
+}
+
+template<typename T>
+void
+f4 ()
+{
+  T i;
+#pragma omp parallel for
+  for (i = ""; i < 4; ++i)     // { dg-error "invalid conversion from" }
+    ;
+}
+
+void
+bar ()
+{
+  f1<0> ();                    // { dg-message "instantiated from here" }
+  f2<1> ();                    // { dg-message "instantiated from here" }
+  f3<int> ();                  // { dg-message "instantiated from here" }
+  f4<int> ();                  // { dg-message "instantiated from here" }
+}