public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] OpenMP: Improve map-clause error message for array function parameter (PR96678)
@ 2020-08-28 16:03 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-08-28 16:03 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3d5ed337cb354c2f85a9caf60377bad887b18d53

commit 3d5ed337cb354c2f85a9caf60377bad887b18d53
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Tue Aug 25 17:46:13 2020 +0200

    OpenMP: Improve map-clause error message for array function parameter (PR96678)
    
    gcc/c/ChangeLog:
    
            PR c/96678
            * c-typeck.c (handle_omp_array_sections_1): Talk about
            array function parameter in the error message.
    
    gcc/cp/ChangeLog:
    
            PR c/96678
            * semantics.c (handle_omp_array_sections_1): Talk about
            array function parameter in the error message.
    
    gcc/testsuite/ChangeLog:
    
            PR c/96678
            * c-c++-common/gomp/map-4.c: New test.
            * c-c++-common/gomp/depend-1.c: Update dg-error.
            * c-c++-common/gomp/map-1.c: Likewise.
            * c-c++-common/gomp/reduction-1.c: Likewise.
            * g++.dg/gomp/depend-1.C: Likewise.
            * g++.dg/gomp/depend-2.C: Likewise.

Diff:
---
 gcc/c/c-typeck.c                              |  9 +++++++--
 gcc/cp/semantics.c                            |  9 +++++++--
 gcc/testsuite/c-c++-common/gomp/depend-1.c    |  2 +-
 gcc/testsuite/c-c++-common/gomp/map-1.c       |  2 +-
 gcc/testsuite/c-c++-common/gomp/map-4.c       | 29 +++++++++++++++++++++++++++
 gcc/testsuite/c-c++-common/gomp/reduction-1.c |  2 +-
 gcc/testsuite/g++.dg/gomp/depend-1.C          |  2 +-
 gcc/testsuite/g++.dg/gomp/depend-2.C          |  2 +-
 8 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 0d639b60ea3..e158d236501 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -13298,8 +13298,13 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
     {
       if (length == NULL_TREE)
 	{
-	  error_at (OMP_CLAUSE_LOCATION (c),
-		    "for pointer type length expression must be specified");
+	  if (C_ARRAY_PARAMETER (ret))
+	    error_at (OMP_CLAUSE_LOCATION (c),
+		      "for array function parameter length expression "
+		      "must be specified");
+	  else
+	    error_at (OMP_CLAUSE_LOCATION (c),
+		      "for pointer type length expression must be specified");
 	  return error_mark_node;
 	}
       if (length != NULL_TREE
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 3877a0e536a..7f861fde7d6 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5083,8 +5083,13 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
     {
       if (length == NULL_TREE)
 	{
-	  error_at (OMP_CLAUSE_LOCATION (c),
-		    "for pointer type length expression must be specified");
+	  if (DECL_ARRAY_PARAMETER_P (ret))
+	    error_at (OMP_CLAUSE_LOCATION (c),
+		      "for array function parameter length expression "
+		      "must be specified");
+	  else
+	    error_at (OMP_CLAUSE_LOCATION (c),
+		      "for pointer type length expression must be specified");
 	  return error_mark_node;
 	}
       if (length != NULL_TREE
diff --git a/gcc/testsuite/c-c++-common/gomp/depend-1.c b/gcc/testsuite/c-c++-common/gomp/depend-1.c
index 8a5850e45fe..599031f2d90 100644
--- a/gcc/testsuite/c-c++-common/gomp/depend-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/depend-1.c
@@ -40,7 +40,7 @@ foo (int g[3][10], int h[4][8], int i[2][10], int j[][9],
     ;
   #pragma omp task depend(out: f[1:10]) /* { dg-error "high bound \[^\n\r]* above array section size" } */
     ;
-  #pragma omp task depend(in: g[:][2:4]) /* { dg-error "for pointer type length expression must be specified" } */
+  #pragma omp task depend(in: g[:][2:4]) /* { dg-error "for array function parameter length expression must be specified" } */
     ;
   #pragma omp task depend(in: h[2:2][-1:]) /* { dg-error "negative low bound in array section" } */
     ;
diff --git a/gcc/testsuite/c-c++-common/gomp/map-1.c b/gcc/testsuite/c-c++-common/gomp/map-1.c
index 5dad7d6a9aa..508dc8d6b01 100644
--- a/gcc/testsuite/c-c++-common/gomp/map-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/map-1.c
@@ -50,7 +50,7 @@ foo (int g[3][10], int h[4][8], int i[2][10], int j[][9],
     bar (e);
   #pragma omp target map(to: f[1:10]) /* { dg-error "high bound \[^\n\r]* above array section size" } */
     bar (f);
-  #pragma omp target map(from: g[:][0:10]) /* { dg-error "for pointer type length expression must be specified" } */
+  #pragma omp target map(from: g[:][0:10]) /* { dg-error "for array function parameter length expression must be specified" } */
     bar (&g[0][0]);
   #pragma omp target map(from: h[2:1][-1:]) /* { dg-error "negative low bound in array section" } */
     bar (&h[0][0]);
diff --git a/gcc/testsuite/c-c++-common/gomp/map-4.c b/gcc/testsuite/c-c++-common/gomp/map-4.c
new file mode 100644
index 00000000000..6c486365bf0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/map-4.c
@@ -0,0 +1,29 @@
+/* PR c/96678.  */
+
+#define SIZE   (100)
+typedef double Grid[SIZE];
+
+void test (Grid src1)
+{
+  #pragma omp target map(alloc:src1[:])  /* { dg-error "for array function parameter length expression must be specified" }  */
+  {
+    src1[0] = 5;
+  }
+}
+
+void test2 (double src2[])
+{
+  #pragma omp target map(alloc:src2[:])  /* { dg-error "for array function parameter length expression must be specified" }  */
+  {
+    src2[0] = 5;
+  }
+}
+
+void test3 (double *src3)
+{
+  #pragma omp target map(alloc:src3[:])  /* { dg-error "for pointer type length expression must be specified" }  */
+  {
+    src3[0] = 5;
+  }
+}
+
diff --git a/gcc/testsuite/c-c++-common/gomp/reduction-1.c b/gcc/testsuite/c-c++-common/gomp/reduction-1.c
index e8dd530b1a4..897ed68e1a3 100644
--- a/gcc/testsuite/c-c++-common/gomp/reduction-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/reduction-1.c
@@ -44,7 +44,7 @@ foo (int a[10][10][10], int **b, int x)
     bar (a);
   #pragma omp parallel reduction(+: f[:][0:2])		/* { dg-error "for unknown bound array type length expression must be specified" } */
     bar (a);
-  #pragma omp parallel reduction(+: a[:][0:10])		/* { dg-error "for pointer type length expression must be specified" } */
+  #pragma omp parallel reduction(+: a[:][0:10])		/* { dg-error "for array function parameter length expression must be specified" } */
     bar (a);
   #pragma omp parallel reduction(+: a[:10][0:12])	/* { dg-error "above array section size" } */
     bar (a);
diff --git a/gcc/testsuite/g++.dg/gomp/depend-1.C b/gcc/testsuite/g++.dg/gomp/depend-1.C
index 33027de552a..81ae27f3ce2 100644
--- a/gcc/testsuite/g++.dg/gomp/depend-1.C
+++ b/gcc/testsuite/g++.dg/gomp/depend-1.C
@@ -35,7 +35,7 @@ foo (int g[3][10], int h[4][8], int i[2][10], int j[][9],
     ;
   #pragma omp task depend(out: f[1:10]) // { dg-error "high bound \[^\n\r]* above array section size" }
     ;
-  #pragma omp task depend(in: g[:][2:4]) // { dg-error "for pointer type length expression must be specified" }
+  #pragma omp task depend(in: g[:][2:4]) // { dg-error "for array function parameter length expression must be specified" }
     ;
   #pragma omp task depend(out: i[:1][11:]) // { dg-error "low bound \[^\n\r]* above array section size" }
     ;
diff --git a/gcc/testsuite/g++.dg/gomp/depend-2.C b/gcc/testsuite/g++.dg/gomp/depend-2.C
index c3f19658c5a..f0f9f60056b 100644
--- a/gcc/testsuite/g++.dg/gomp/depend-2.C
+++ b/gcc/testsuite/g++.dg/gomp/depend-2.C
@@ -41,7 +41,7 @@ foo (int g[3][10], int h[4][8], int i[2][10], int j[][9],
     ;
   #pragma omp task depend(out: f[1:10]) // { dg-error "high bound \[^\n\r]* above array section size" }
     ;
-  #pragma omp task depend(in: g[:][2:4]) // { dg-error "for pointer type length expression must be specified" }
+  #pragma omp task depend(in: g[:][2:4]) // { dg-error "for array function parameter length expression must be specified" }
     ;
   #pragma omp task depend(in: h[2:2][-1:]) // { dg-error "negative low bound in array section" }
     ;


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

only message in thread, other threads:[~2020-08-28 16:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 16:03 [gcc/devel/c++-modules] OpenMP: Improve map-clause error message for array function parameter (PR96678) Nathan Sidwell

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).