From patchwork Tue Aug 25 15:33:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1351134 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BbY0n2p2lz9sTd for ; Wed, 26 Aug 2020 01:33:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AF4CA3861038; Tue, 25 Aug 2020 15:33:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id BD92E3857807 for ; Tue, 25 Aug 2020 15:33:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BD92E3857807 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: nxpnXh85vcFYmvrOTm2hFiTZM7xVfdNMAyJg2BSSaEjQfwFv2RAY7EpqOHrSG/4Vnl938nFX/4 UEHdAQGa3tMvX0Cm3v3F6+gr5ponmHxEhbZ8drA21n5T6746F07T0khsGh3I6xkcgqO85+/nCJ DKfjeWtoN1ZslD658mN6fC1LwNzCTVxVQHSnRQmf1OdFG/a5YHVH/iELQEFtUeTHdbQC1GAWtM Dgzq585W2VHQ0ftXsZL3HCpA57synTUAEN8sA9Ypp3ThrDQ1410WeusEl8sVndX568fG3cBUtw 2n0= X-IronPort-AV: E=Sophos;i="5.76,353,1592899200"; d="diff'?scan'208";a="52229631" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 25 Aug 2020 07:33:05 -0800 IronPort-SDR: 9Fhp1zCGwhW/pQuDiYMh7idZcvgv+wW44ZrZfVe02p6u29MRJqHJH4rjxF364oGL5J+Y22Sr6v AMSHBZb2FHWxFmLPaQGpbjSFA3RgDQza1zdUPj23gcs5jeHykCYLrnYUkyYjlFDPiLOBL3GPD3 xPgnRSB/dsVnhrQnAQxGtn+l3jOb0VDOxnM2h3Fs1oNEn/whhIt8j9YNpnAYGCm6yoECfb4UCK G6ahJWQhwoW/DyrcV5qj+SulF430eO5aVIP6zHtFlrChCSF6YEjxkcp8xH7mgCILqZqkZ16APg Qjk= To: gcc-patches , Jakub Jelinek From: Tobias Burnus Subject: [Patch] OpenMP: Improve map-clause error message for array function parameter (PR96678) Message-ID: <9d78cc86-07ec-a1e3-bfba-02fdc832d6bf@codesourcery.com> Date: Tue, 25 Aug 2020 17:33:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" 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 &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 &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" } ;