re PR c++/35337 (Broken diagnostic for firstprivate clause)
authorJakub Jelinek <jakub@redhat.com>
Mon, 10 Mar 2008 19:43:16 +0000 (20:43 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 10 Mar 2008 19:43:16 +0000 (20:43 +0100)
PR c++/35337
* semantics.c (finish_omp_clauses): Use %qD instead of %qE for
DECL_P in not a variable and appears more than once error messages.

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

From-SVN: r133086

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

index 6415063aa7912dc713239e67d4e1b644d74ab11d..4ae8f17330fd28e8cdd5a48d168afe7a5da2aead 100644 (file)
@@ -1,3 +1,9 @@
+2008-03-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/35337
+       * semantics.c (finish_omp_clauses): Use %qD instead of %qE for
+       DECL_P in not a variable and appears more than once error messages.
+
 2008-03-07  Paolo Bonzini  <bonzini@gnu.org>
 
        Revert:
index 472c5cc72f2d8e9db59b13ce1a8774d4c623e119..2ee67cbf4dce53ffd11bc6da0de097121681798d 100644 (file)
@@ -3400,13 +3400,16 @@ finish_omp_clauses (tree clauses)
            {
              if (processing_template_decl)
                break;
-             error ("%qE is not a variable in clause %<firstprivate%>", t);
+             if (DECL_P (t))
+               error ("%qD is not a variable in clause %<firstprivate%>", t);
+             else
+               error ("%qE is not a variable in clause %<firstprivate%>", t);
              remove = true;
            }
          else if (bitmap_bit_p (&generic_head, DECL_UID (t))
                   || bitmap_bit_p (&firstprivate_head, DECL_UID (t)))
            {
-             error ("%qE appears more than once in data clauses", t);
+             error ("%qD appears more than once in data clauses", t);
              remove = true;
            }
          else
@@ -3419,13 +3422,16 @@ finish_omp_clauses (tree clauses)
            {
              if (processing_template_decl)
                break;
-             error ("%qE is not a variable in clause %<lastprivate%>", t);
+             if (DECL_P (t))
+               error ("%qD is not a variable in clause %<lastprivate%>", t);
+             else
+               error ("%qE is not a variable in clause %<lastprivate%>", t);
              remove = true;
            }
          else if (bitmap_bit_p (&generic_head, DECL_UID (t))
                   || bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
            {
-             error ("%qE appears more than once in data clauses", t);
+             error ("%qD appears more than once in data clauses", t);
              remove = true;
            }
          else
index 1427ceaae92e60bcefd7f0f4ddf4d3e25ed79127..22c6ee8163991cec3109fedbe4c4a22fbb8aa76e 100644 (file)
@@ -1,5 +1,8 @@
 2008-03-10  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/35337
+       * g++.dg/gomp/pr35337.C: New test.
+
        PR c/35438
        PR c/35439
        * gcc.dg/gomp/pr35438.c: New test.
diff --git a/gcc/testsuite/g++.dg/gomp/pr35337.C b/gcc/testsuite/g++.dg/gomp/pr35337.C
new file mode 100644 (file)
index 0000000..2e9ca6b
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/35337
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+struct A { };
+
+void
+foo ()
+{
+#pragma omp parallel firstprivate(A)   // { dg-error "struct A\[^\n\]*is not a variable" }
+  ;
+}
+
+void
+bar ()
+{
+#pragma omp for lastprivate(A)         // { dg-error "struct A\[^\n\]*is not a variable" }
+  for (int i = 0; i < 10; i++)
+    ;
+}