]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openacc: fix ICE for non-decl expression in non-contiguous array base-pointer
authorChung-Lin Tang <cltang@codesourcery.com>
Thu, 19 Aug 2021 08:17:02 +0000 (16:17 +0800)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 21 Jun 2022 13:11:40 +0000 (14:11 +0100)
Currently, we do not support cases like struct-members as the base-pointer
for an OpenACC non-contiguous array. Mark such cases as unsupported in the
C/C++ front-ends, instead of ICEing on them.

gcc/c/ChangeLog:

* c-typeck.cc (handle_omp_array_sections_1): Robustify non-contiguous
array check and reject non-DECL base-pointer cases as unsupported.

gcc/cp/ChangeLog:

* semantics.cc (handle_omp_array_sections_1): Robustify non-contiguous
array check and reject non-DECL base-pointer cases as unsupported.

gcc/c/ChangeLog.omp
gcc/c/c-typeck.cc
gcc/cp/ChangeLog.omp
gcc/cp/semantics.cc

index 9c7daa193a98f4e9c4e9bc42509d2b19964456a4..73b6bb1f78b8e61bfc59ae1ed6c6c15f210f1864 100644 (file)
@@ -1,3 +1,8 @@
+2021-08-19  Chung-Lin Tang  <cltang@codesourcery.com>
+
+       * c-typeck.cc (handle_omp_array_sections_1): Robustify non-contiguous
+       array check and reject non-DECL base-pointer cases as unsupported.
+
 2021-02-02  Chung-Lin Tang  <cltang@codesourcery.com>
 
        * c-parser.cc (c_parser_declaration_or_fndef): Set
index 2965bd74cfc998e5c6a5a3a4bc9894ba3d4baab8..32bf33e80d6955f4668d9870e26495fd50713774 100644 (file)
@@ -13576,14 +13576,27 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
              if (d_length == NULL_TREE || !integer_onep (d_length))
                {
                  if (ort == C_ORT_ACC)
-                   non_contiguous = true;
-                 else
                    {
+                     while (TREE_CODE (d) == TREE_LIST)
+                       d = TREE_CHAIN (d);
+                     if (DECL_P (d))
+                       {
+                         /* Note that OpenACC does accept these kinds of
+                            non-contiguous pointer based arrays.  */
+                         non_contiguous = true;
+                         break;
+                       }
                      error_at (OMP_CLAUSE_LOCATION (c),
-                               "array section is not contiguous in %qs clause",
+                               "base-pointer expression in %qs clause not "
+                               "supported for non-contiguous arrays",
                                omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
                      return error_mark_node;
                    }
+
+                 error_at (OMP_CLAUSE_LOCATION (c),
+                           "array section is not contiguous in %qs clause",
+                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+                 return error_mark_node;
                }
            }
        }
index efda4eddf14a9feb25969dd81d21e8cae2e3fafd..bd0dbe8ba422910bc597d0b44c27057bfc65c27e 100644 (file)
@@ -1,3 +1,8 @@
+2021-08-19  Chung-Lin Tang  <cltang@codesourcery.com>
+
+       * semantics.cc (handle_omp_array_sections_1): Robustify non-contiguous
+       array check and reject non-DECL base-pointer cases as unsupported.
+
 2021-03-03  Chung-Lin Tang  <cltang@codesourcery.com>
 
        * decl2.cc (cp_omp_mappable_type_1): Allow fields with
index daef4fb581e97ed801759550536108ebe66c9cd5..539bdca7eb0fee814110f03c50ee4025e5f6ba3e 100644 (file)
@@ -5396,9 +5396,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
          return error_mark_node;
        }
       /* If there is a pointer type anywhere but in the very first
-        array-section-subscript, the array section could be non-contiguous.
-        Note that OpenACC does accept these kinds of non-contiguous pointer
-        based arrays.  */
+        array-section-subscript, the array section could be non-contiguous.  */
       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
          && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
          && TREE_CODE (TREE_CHAIN (t)) == TREE_LIST)
@@ -5412,14 +5410,27 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
              if (d_length == NULL_TREE || !integer_onep (d_length))
                {
                  if (ort == C_ORT_ACC)
-                   non_contiguous = true;
-                 else
                    {
+                     while (TREE_CODE (d) == TREE_LIST)
+                       d = TREE_CHAIN (d);
+                     if (DECL_P (d))
+                       {
+                         /* Note that OpenACC does accept these kinds of
+                            non-contiguous pointer based arrays.  */
+                         non_contiguous = true;
+                         break;
+                       }
                      error_at (OMP_CLAUSE_LOCATION (c),
-                               "array section is not contiguous in %qs clause",
+                               "base-pointer expression in %qs clause not "
+                               "supported for non-contiguous arrays",
                                omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
                      return error_mark_node;
                    }
+
+                 error_at (OMP_CLAUSE_LOCATION (c),
+                           "array section is not contiguous in %qs clause",
+                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+                 return error_mark_node;
                }
            }
        }