Improve the error message. Currently code like:
void test (double src[100])
{
#pragma omp target map(alloc:src[:])
fails with the surprising
"for pointer type length expression must be specified"
as "double src[100]" is regarded as "double *src".
Thus, one cannot simply extract the "100" and internally
replace src[:] by src[0:100].
However, by talking about "array function parameter",
I think the error message is at least a bit clearer.
OK?
Tobias
-
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander
Walter
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.
* gcc/testsuite/g++.dg/gomp/depend-1.C: Likewise.
* gcc/testsuite/g++.dg/gomp/depend-2.C: Likewise.
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 ,
{
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 ,
{
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 ([0][0]);
#pragma omp target map(from: h[2:1][-1:]) /* { dg-error "negative low bound in array section" } */
bar ([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