]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/85696 (OpenMP with variably modified and default(none) won't compile)
authorJakub Jelinek <jakub@redhat.com>
Fri, 22 Jun 2018 21:25:04 +0000 (23:25 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Jun 2018 21:25:04 +0000 (23:25 +0200)
Backported from mainline
2018-05-11  Jakub Jelinek  <jakub@redhat.com>

PR c/85696
* c-omp.c (c_omp_predetermined_sharing): Return
OMP_CLAUSE_DEFAULT_SHARED for artificial vars with integral type.

* c-typeck.c (c_finish_omp_clauses): Don't use
c_omp_predetermined_sharing, instead just check TREE_READONLY.

* cp-tree.h (cxx_omp_predetermined_sharing_1): New prototype.
* cp-gimplify.c (cxx_omp_predetermined_sharing): New wrapper around
cxx_omp_predetermined_sharing_1.  Rename old function to ...
(cxx_omp_predetermined_sharing_1): ... this.
* semantics.c (finish_omp_clauses): Use cxx_omp_predetermined_sharing_1
instead of cxx_omp_predetermined_sharing.

* c-c++-common/gomp/pr85696.c: New test.

From-SVN: r261963

gcc/c-family/ChangeLog
gcc/c-family/c-omp.c
gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/cp/cp-tree.h
gcc/cp/semantics.c
gcc/testsuite/ChangeLog

index e2c7ea36b201ca598b2d0d6b51aa12087027a755..00653a6029da09c239377ab11cfea0e61af436c8 100644 (file)
@@ -1,6 +1,12 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-05-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/85696
+       * c-omp.c (c_omp_predetermined_sharing): Return
+       OMP_CLAUSE_DEFAULT_SHARED for artificial vars with integral type.
+
        2018-05-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/85662
index 977cb0ea15303d22486769541faf070cfcb91002..eee718ddce10489fbfcbc0e8ff9c3e8325be1e65 100644 (file)
@@ -1540,5 +1540,13 @@ c_omp_predetermined_sharing (tree decl)
   if (TREE_READONLY (decl))
     return OMP_CLAUSE_DEFAULT_SHARED;
 
+  /* Predetermine artificial variables holding integral values, those
+     are usually result of gimplify_one_sizepos or SAVE_EXPR
+     gimplification.  */
+  if (VAR_P (decl)
+      && DECL_ARTIFICIAL (decl)
+      && INTEGRAL_TYPE_P (TREE_TYPE (decl)))
+    return OMP_CLAUSE_DEFAULT_SHARED;
+
   return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
 }
index 9370bef39180e7e639c18672b3420d0eab140972..35f93f6ef3e69f7c1c1d3c463be6fc0e6f000e79 100644 (file)
@@ -1,6 +1,12 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-05-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/85696
+       * c-typeck.c (c_finish_omp_clauses): Don't use
+       c_omp_predetermined_sharing, instead just check TREE_READONLY.
+
        2018-05-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/85662
index 2c87ec9875a73a27e241241b800ddb9bdad24a9a..66a58a81e71fe1c92bd2c516f2d929e1d8eb48e6 100644 (file)
@@ -13760,22 +13760,11 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 
              if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
                share_name = "threadprivate";
-             else switch (c_omp_predetermined_sharing (t))
+             else if (TREE_READONLY (t))
                {
-               case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
-                 break;
-               case OMP_CLAUSE_DEFAULT_SHARED:
                  /* const vars may be specified in firstprivate clause.  */
-                 if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE
-                     && TREE_READONLY (t))
-                   break;
-                 share_name = "shared";
-                 break;
-               case OMP_CLAUSE_DEFAULT_PRIVATE:
-                 share_name = "private";
-                 break;
-               default:
-                 gcc_unreachable ();
+                 if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_FIRSTPRIVATE)
+                   share_name = "shared";
                }
              if (share_name)
                {
index effd4a7b27d6739cfb44fd2ae7c0e249a7b9ad8b..9a6c7dc9adb1eae4c29a6f1cefa3acce67d9873f 100644 (file)
@@ -1,6 +1,16 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-05-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/85696
+       * cp-tree.h (cxx_omp_predetermined_sharing_1): New prototype.
+       * cp-gimplify.c (cxx_omp_predetermined_sharing): New wrapper around
+       cxx_omp_predetermined_sharing_1.  Rename old function to ...
+       (cxx_omp_predetermined_sharing_1): ... this.
+       * semantics.c (finish_omp_clauses): Use cxx_omp_predetermined_sharing_1
+       instead of cxx_omp_predetermined_sharing.
+
        2018-05-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/85662
index 5f5274a0ce3aed1984e941e4de970aec47079b47..4891346a609bdab996efbb2d6cd0bd6e80720130 100644 (file)
@@ -1918,7 +1918,7 @@ cxx_omp_const_qual_no_mutable (tree decl)
 /* True if OpenMP sharing attribute of DECL is predetermined.  */
 
 enum omp_clause_default_kind
-cxx_omp_predetermined_sharing (tree decl)
+cxx_omp_predetermined_sharing_1 (tree decl)
 {
   /* Static data members are predetermined shared.  */
   if (TREE_STATIC (decl))
@@ -1936,6 +1936,32 @@ cxx_omp_predetermined_sharing (tree decl)
   return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
 }
 
+/* Likewise, but also include the artificial vars.  We don't want to
+   disallow the artificial vars being mentioned in explicit clauses,
+   as we use artificial vars e.g. for loop constructs with random
+   access iterators other than pointers, but during gimplification
+   we want to treat them as predetermined.  */
+
+enum omp_clause_default_kind
+cxx_omp_predetermined_sharing (tree decl)
+{
+  enum omp_clause_default_kind ret = cxx_omp_predetermined_sharing_1 (decl);
+  if (ret != OMP_CLAUSE_DEFAULT_UNSPECIFIED)
+    return ret;
+
+  /* Predetermine artificial variables holding integral values, those
+     are usually result of gimplify_one_sizepos or SAVE_EXPR
+     gimplification.  */
+  if (VAR_P (decl)
+      && DECL_ARTIFICIAL (decl)
+      && INTEGRAL_TYPE_P (TREE_TYPE (decl))
+      && !(DECL_LANG_SPECIFIC (decl)
+          && DECL_OMP_PRIVATIZED_MEMBER (decl)))
+    return OMP_CLAUSE_DEFAULT_SHARED;
+
+  return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
+}
+
 /* Finalize an implicitly determined clause.  */
 
 void
index 25d404bc609c58f179d511ca5a90809860591156..664def60405864b80ab32feab0c8271f97df11cb 100644 (file)
@@ -6943,6 +6943,7 @@ extern int cp_gimplify_expr                       (tree *, gimple_seq *,
                                                 gimple_seq *);
 extern void cp_genericize                      (tree);
 extern bool cxx_omp_const_qual_no_mutable      (tree);
+extern enum omp_clause_default_kind cxx_omp_predetermined_sharing_1 (tree);
 extern enum omp_clause_default_kind cxx_omp_predetermined_sharing (tree);
 extern tree cxx_omp_clause_default_ctor                (tree, tree, tree);
 extern tree cxx_omp_clause_copy_ctor           (tree, tree, tree);
index 52ca2a53efc08cfd343015651892be6179770372..34ca72e10a0ac71c77146607da0c066a0094ff9c 100644 (file)
@@ -7371,7 +7371,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
 
          if (VAR_P (t) && CP_DECL_THREAD_LOCAL_P (t))
            share_name = "threadprivate";
-         else switch (cxx_omp_predetermined_sharing (t))
+         else switch (cxx_omp_predetermined_sharing_1 (t))
            {
            case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
              break;
index dd4c71e9baf3ef04a86ff544d88091bcd0b01c2a..7669f256a4468a894145de068e5376f90253edd2 100644 (file)
@@ -6,6 +6,11 @@
        PR c++/85662
        * g++.dg/ext/offsetof3.C: New test.
 
+       2018-05-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/85696
+       * c-c++-common/gomp/pr85696.c: New test.
+
        2018-05-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/85662