]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/81154 (OpenMP with shared variable in a template class crash)
authorJakub Jelinek <jakub@redhat.com>
Wed, 21 Jun 2017 18:30:32 +0000 (20:30 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 21 Jun 2017 18:30:32 +0000 (20:30 +0200)
PR c++/81154
* semantics.c (handle_omp_array_sections_1, finish_omp_clauses):
Complain about t not being a variable if t is OVERLOAD even
when processing_template_decl.

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

From-SVN: r249467

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

index 7d50a0b74f87d2340229d4846bb8b17e79f698dd..c11cbe428d62cf6f2e1db853e4ed76cab36217ce 100644 (file)
@@ -1,3 +1,10 @@
+2017-06-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/81154
+       * semantics.c (handle_omp_array_sections_1, finish_omp_clauses):
+       Complain about t not being a variable if t is OVERLOAD even
+       when processing_template_decl.
+
 2017-06-21  David Malcolm  <dmalcolm@redhat.com>
 
        * parser.c (get_cast_suggestion): New function.
index 5fe772a49e38982f424de8ae06ffc544af5805a0..7ecc6324a336fe07d65f5fe1798aed7238957ea3 100644 (file)
@@ -4589,7 +4589,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
        }
       if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
        {
-         if (processing_template_decl)
+         if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
            return NULL_TREE;
          if (DECL_P (t))
            error_at (OMP_CLAUSE_LOCATION (c),
@@ -6109,7 +6109,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
          if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL
              && (!field_ok || TREE_CODE (t) != FIELD_DECL))
            {
-             if (processing_template_decl)
+             if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
                break;
              if (DECL_P (t))
                error ("%qD is not a variable in clause %qs", t,
@@ -6181,7 +6181,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
              && ((ort & C_ORT_OMP_DECLARE_SIMD) != C_ORT_OMP
                  || TREE_CODE (t) != FIELD_DECL))
            {
-             if (processing_template_decl)
+             if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
                break;
              if (DECL_P (t))
                error ("%qD is not a variable in clause %<firstprivate%>", t);
@@ -6224,7 +6224,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
              && ((ort & C_ORT_OMP_DECLARE_SIMD) != C_ORT_OMP
                  || TREE_CODE (t) != FIELD_DECL))
            {
-             if (processing_template_decl)
+             if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
                break;
              if (DECL_P (t))
                error ("%qD is not a variable in clause %<lastprivate%>", t);
@@ -6587,7 +6587,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
            }
          if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
            {
-             if (processing_template_decl)
+             if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
                break;
              if (DECL_P (t))
                error ("%qD is not a variable in %<aligned%> clause", t);
@@ -6669,7 +6669,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
            remove = true;
          else if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
            {
-             if (processing_template_decl)
+             if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
                break;
              if (DECL_P (t))
                error ("%qD is not a variable in %<depend%> clause", t);
@@ -6800,7 +6800,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
            }
          if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
            {
-             if (processing_template_decl)
+             if (processing_template_decl && TREE_CODE (t) != OVERLOAD)
                break;
              if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
                  && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER
index 446e234a1e2fabc1a8feea7fa406a9c130eb5ae4..0239d5aeb70863a9ecfe5a969a97ed0b79cb0a8d 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/81154
+       * g++.dg/gomp/pr81154.C: New test.
+
 2017-06-21  David Malcolm  <dmalcolm@redhat.com>
 
        * g++.dg/other/old-style-cast-fixits.C: New test case.
diff --git a/gcc/testsuite/g++.dg/gomp/pr81154.C b/gcc/testsuite/g++.dg/gomp/pr81154.C
new file mode 100644 (file)
index 0000000..dc0aec3
--- /dev/null
@@ -0,0 +1,57 @@
+// PR c++/81154
+// { dg-do compile }
+
+template <typename T>
+struct C
+{
+  int foo (T n) const
+  {
+#pragma omp parallel shared (foo)      // { dg-error "is not a variable in clause" }
+    ;
+#pragma omp parallel private (foo)     // { dg-error "is not a variable in clause" }
+    ;
+#pragma omp parallel firstprivate (foo)        // { dg-error "is not a variable in clause" }
+    ;
+#pragma omp parallel for lastprivate (foo)     // { dg-error "is not a variable in clause" }
+    for (T i = 0; i < n; i++)
+      ;
+#pragma omp parallel for linear (foo)  // { dg-error "is not a variable in clause" }
+    for (T i = 0; i < n; i++)
+      ;
+#pragma omp parallel reduction (+:foo) // { dg-error "is not a variable in clause" }
+    ;
+    return 0;
+  }
+  int foo (int x, int y) { return x; }
+};
+
+struct D
+{
+  typedef int T;
+  int foo (T n) const
+  {
+#pragma omp parallel shared (foo)      // { dg-error "is not a variable in clause" }
+    ;
+#pragma omp parallel private (foo)     // { dg-error "is not a variable in clause" }
+    ;
+#pragma omp parallel firstprivate (foo)        // { dg-error "is not a variable in clause" }
+    ;
+#pragma omp parallel for lastprivate (foo)     // { dg-error "is not a variable in clause" }
+    for (T i = 0; i < n; i++)
+      ;
+#pragma omp parallel for linear (foo)  // { dg-error "is not a variable in clause" }
+    for (T i = 0; i < n; i++)
+      ;
+#pragma omp parallel reduction (+:foo) // { dg-error "is not a variable in clause" }
+    ;
+    return 0;
+  }
+  int foo (int x, int y) { return x; }
+};
+
+int
+main ()
+{
+  C<int> ().foo (1);
+  D ().foo (1);
+}