]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/81130 (ICE OpenMP shared clause in gimplify_var_or_parm_decl...
authorJakub Jelinek <jakub@redhat.com>
Thu, 22 Jun 2017 11:24:43 +0000 (13:24 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 22 Jun 2017 11:24:43 +0000 (13:24 +0200)
Backported from mainline
2017-06-21  Jakub Jelinek  <jakub@redhat.com>

PR c++/81130
* gimplify.c (omp_add_variable): Don't force GOVD_SEEN for types
with ctors/dtors if GOVD_SHARED is set.

* testsuite/libgomp.c++/pr81130.C: New test.

From-SVN: r249527

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

index 494ba3f6fc0aa87366a7a4f74dab6200d133f47d..e8acb90b6b54cbf008d086785aa5323228c2c231 100644 (file)
@@ -1,6 +1,12 @@
 2017-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-06-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/81130
+       * gimplify.c (omp_add_variable): Don't force GOVD_SEEN for types
+       with ctors/dtors if GOVD_SHARED is set.
+
        2017-06-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/80973
index 991f0fbe4069c5b74de70b7f7b9e75211071e210..ee9eaea4ed7999f8f8c1cce9c1acf355750ea6e0 100644 (file)
@@ -4531,7 +4531,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),
@@ -6013,7 +6013,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd)
          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,
@@ -6069,7 +6069,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd)
          if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL
              && (!allow_fields || 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);
@@ -6108,7 +6108,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd)
          if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL
              && (!allow_fields || 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);
@@ -6458,7 +6458,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd)
            }
          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);
@@ -6540,7 +6540,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd)
            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);
@@ -6668,7 +6668,7 @@ finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd)
            }
          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 0e5404b21fc4ead5454bba621a70006daba9b470..bdc2490b4bc11eb4b37bab7702dc510a1d310eb0 100644 (file)
@@ -1,3 +1,11 @@
+2017-06-22  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2017-06-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/81130
+       * testsuite/libgomp.c++/pr81130.C: New test.
+
 2017-06-22  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
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);
+}