summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/c-omp.c3
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/gomp/for-19.C41
-rw-r--r--libgomp/ChangeLog5
-rw-r--r--libgomp/testsuite/libgomp.c++/for-6.C109
6 files changed, 164 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 05b970b7f46..5d7f4f03b7c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,9 @@
2008-12-01 Jakub Jelinek <jakub@redhat.com>
+ PR c++/38348
+ * c-omp.c (c_finish_omp_for): Only transform pointer
+ ++ or -- into MODIFY_EXPR if second argument is non-NULL.
+
PR rtl-optimization/38245
* tree-vrp.c (abs_extent_range): New function.
(extract_range_from_binary_expr): Compute range
diff --git a/gcc/c-omp.c b/gcc/c-omp.c
index b06c83039b9..3be3729a32c 100644
--- a/gcc/c-omp.c
+++ b/gcc/c-omp.c
@@ -357,7 +357,8 @@ c_finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
break;
incr_ok = true;
- if (POINTER_TYPE_P (TREE_TYPE (decl)))
+ if (POINTER_TYPE_P (TREE_TYPE (decl))
+ && TREE_OPERAND (incr, 1))
{
tree t = fold_convert (sizetype, TREE_OPERAND (incr, 1));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 88adf43bda1..1bc5714a64c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2008-12-01 Jakub Jelinek <jakub@redhat.com>
+ PR c++/38348
+ * g++.dg/gomp/for-19.C: New test.
+
PR rtl-optimization/38245
* gcc.dg/pr38245-1.c: New test.
* gcc.dg/pr38245-2.c: New test.
diff --git a/gcc/testsuite/g++.dg/gomp/for-19.C b/gcc/testsuite/g++.dg/gomp/for-19.C
new file mode 100644
index 00000000000..1929e45f884
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/for-19.C
@@ -0,0 +1,41 @@
+// PR c++/38348
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+const char *p = "abcde";
+
+template <typename T>
+void
+f1 (void)
+{
+#pragma omp for // { dg-error "forbids incrementing a pointer of type" }
+ for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" }
+ ;
+}
+
+template <typename T>
+void
+f2 (void)
+{
+#pragma omp for
+ for (const char *q = p; q < p + 4; q++)
+ ;
+}
+
+template <typename T>
+void
+f3 (void)
+{
+#pragma omp for // { dg-error "forbids incrementing a pointer of type" }
+ for (T q = T (p); q < T (p + 4); q++)
+ ;
+}
+
+int
+main (void)
+{
+ f1 <int> (); // { dg-message "instantiated from here" }
+ f2 <int> ();
+ f3 <const char *> ();
+ f3 <void *> (); // { dg-message "instantiated from here" }
+}
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 0cdfba6d83f..5576af2049c 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2008-12-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/38348
+ * testsuite/libgomp.c++/for-6.C: New test.
+
2008-11-26 Janis Johnson <janis187@us.ibm.com>
PR testsuite/28870
diff --git a/libgomp/testsuite/libgomp.c++/for-6.C b/libgomp/testsuite/libgomp.c++/for-6.C
new file mode 100644
index 00000000000..0da21ce2fe5
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/for-6.C
@@ -0,0 +1,109 @@
+// PR c++/38348
+// { dg-do run }
+
+extern "C" void abort ();
+int cnt;
+
+template <typename T>
+void
+f0 (T, int)
+{
+ abort ();
+}
+
+template <>
+void
+f0<int> (int, int type)
+{
+ if (type != 0)
+ abort ();
+#pragma omp atomic
+ cnt++;
+}
+
+template <>
+void
+f0<const char *> (const char *, int type)
+{
+ if (type != 1)
+ abort ();
+#pragma omp atomic
+ cnt++;
+}
+
+template <typename T>
+void
+f1 ()
+{
+#pragma omp parallel for
+ for (int i = 0; i < 10; i++)
+ f0 (i, 0);
+}
+
+template <typename T>
+void
+f2 ()
+{
+#pragma omp parallel for
+ for (T i = T (0); i < T (10); i += T (1))
+ f0 (i, 0);
+}
+
+void
+f3 ()
+{
+#pragma omp parallel for
+ for (int i = 0; i < 10; i++)
+ f0 (i, 0);
+}
+
+const char *p = "abcdefghij";
+
+template <typename T>
+void
+f4 ()
+{
+#pragma omp parallel for
+ for (const char *i = p; i < p + 10; i += 1)
+ f0 (i, 1);
+}
+
+template <typename T>
+void
+f5 ()
+{
+#pragma omp parallel for
+ for (T i = T (p); i < T (p + 10); i += 1)
+ f0 (i, 1);
+}
+
+void
+f6 ()
+{
+#pragma omp parallel for
+ for (const char *i = p; i < p + 10; i++)
+ f0 (i, 1);
+}
+
+int
+main ()
+{
+ f1<int> ();
+ if (cnt != 10)
+ abort ();
+ f2<int> ();
+ if (cnt != 20)
+ abort ();
+ f3 ();
+ if (cnt != 30)
+ abort ();
+ f4<int> ();
+ if (cnt != 40)
+ abort ();
+ f5<const char *> ();
+ if (cnt != 50)
+ abort ();
+ f6 ();
+ if (cnt != 60)
+ abort ();
+}