]> 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)
committerChung-Lin Tang <cltang@codesourcery.com>
Thu, 19 Aug 2021 11:42:33 +0000 (19:42 +0800)
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.c (handle_omp_array_sections_1): Robustify non-contiguous
array check and reject non-DECL base-pointer cases as unsupported.

gcc/cp/ChangeLog:

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

gcc/c/c-typeck.c
gcc/cp/semantics.c

index 9c4822bbf27a3461101329b064a8b1883e87d5f2..a8b54c676c02485ce577d6a57d9d728e55433150 100644 (file)
@@ -13431,25 +13431,36 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
          && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
          && TREE_CODE (TREE_CHAIN (t)) == TREE_LIST)
        {
-         if (ort == C_ORT_ACC)
-           /* Note that OpenACC does accept these kinds of non-contiguous
-              pointer based arrays.  */
-           non_contiguous = true;
-         else
+         /* If any prior dimension has a non-one length, then deem this
+            array section as non-contiguous.  */
+         for (tree d = TREE_CHAIN (t); TREE_CODE (d) == TREE_LIST;
+              d = TREE_CHAIN (d))
            {
-             /* If any prior dimension has a non-one length, then deem this
-                array section as non-contiguous.  */
-             for (tree d = TREE_CHAIN (t); TREE_CODE (d) == TREE_LIST;
-                  d = TREE_CHAIN (d))
+             tree d_length = TREE_VALUE (d);
+             if (d_length == NULL_TREE || !integer_onep (d_length))
                {
-                 tree d_length = TREE_VALUE (d);
-                 if (d_length == NULL_TREE || !integer_onep (d_length))
+                 if (ort == C_ORT_ACC)
                    {
+                     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 e56ad8aa1e1fb4240a476f23b24ac518da699b3d..ad62ad76ff914dab4febbb3c94ff2b580fff05b6 100644 (file)
@@ -5292,32 +5292,41 @@ 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)
        {
-         if (ort == C_ORT_ACC)
-           /* Note that OpenACC does accept these kinds of non-contiguous
-              pointer based arrays.  */
-           non_contiguous = true;
-         else
+         /* If any prior dimension has a non-one length, then deem this
+            array section as non-contiguous.  */
+         for (tree d = TREE_CHAIN (t); TREE_CODE (d) == TREE_LIST;
+              d = TREE_CHAIN (d))
            {
-             /* If any prior dimension has a non-one length, then deem this
-                array section as non-contiguous.  */
-             for (tree d = TREE_CHAIN (t); TREE_CODE (d) == TREE_LIST;
-                  d = TREE_CHAIN (d))
+             tree d_length = TREE_VALUE (d);
+             if (d_length == NULL_TREE || !integer_onep (d_length))
                {
-                 tree d_length = TREE_VALUE (d);
-                 if (d_length == NULL_TREE || !integer_onep (d_length))
+                 if (ort == C_ORT_ACC)
                    {
+                     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;
                }
            }
        }