public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] openacc: fix ICE for non-decl expression in non-contiguous array base-pointer
@ 2021-08-19 11:43 Chung-Lin Tang
  0 siblings, 0 replies; only message in thread
From: Chung-Lin Tang @ 2021-08-19 11:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4e34710679ac084d7ca15ccf387c1b6f1e64c2d1

commit 4e34710679ac084d7ca15ccf387c1b6f1e64c2d1
Author: Chung-Lin Tang <cltang@codesourcery.com>
Date:   Thu Aug 19 16:17:02 2021 +0800

    openacc: fix ICE for non-decl expression in non-contiguous array base-pointer
    
    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.

Diff:
---
 gcc/c/c-typeck.c   | 35 +++++++++++++++++++++++------------
 gcc/cp/semantics.c | 39 ++++++++++++++++++++++++---------------
 2 files changed, 47 insertions(+), 27 deletions(-)

diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 9c4822bbf27..a8b54c676c0 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -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;
 		}
 	    }
 	}
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index e56ad8aa1e1..ad62ad76ff9 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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;
 		}
 	    }
 	}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-19 11:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 11:43 [gcc/devel/omp/gcc-11] openacc: fix ICE for non-decl expression in non-contiguous array base-pointer Chung-Lin Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).