aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-08-25 17:46:13 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-08-25 17:46:41 +0200
commit3d5ed337cb354c2f85a9caf60377bad887b18d53 (patch)
tree1f1fbb20cd42c8e5c8e77d63f3116ae91a23f4cb /gcc
parent24f2764521d8f27760f03f626a4f20f4c82b7c73 (diff)
downloadgcc-3d5ed337cb354c2f85a9caf60377bad887b18d53.zip
gcc-3d5ed337cb354c2f85a9caf60377bad887b18d53.tar.gz
gcc-3d5ed337cb354c2f85a9caf60377bad887b18d53.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/c-typeck.c9
-rw-r--r--gcc/cp/semantics.c9
-rw-r--r--gcc/testsuite/c-c++-common/gomp/depend-1.c2
-rw-r--r--gcc/testsuite/c-c++-common/gomp/map-1.c2
-rw-r--r--gcc/testsuite/c-c++-common/gomp/map-4.c29
-rw-r--r--gcc/testsuite/c-c++-common/gomp/reduction-1.c2
-rw-r--r--gcc/testsuite/g++.dg/gomp/depend-1.C2
-rw-r--r--gcc/testsuite/g++.dg/gomp/depend-2.C2
8 files changed, 48 insertions, 9 deletions
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 0d639b60..e158d23 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 3877a0e..7f861fd 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 8a5850e..599031f 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 5dad7d6..508dc8d 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 0000000..6c48636
--- /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 e8dd530..897ed68 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 33027de..81ae27f 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 c3f1965..f0f9f60 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" }
;