From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5046 invoked by alias); 29 Jul 2016 04:21:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 5028 invoked by uid 89); 29 Jul 2016 04:21:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=MODULE, CONTAINS X-Spam-User: qpsmtpd, 2 recipients X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 29 Jul 2016 04:21:33 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtp id 1bSzIg-000226-DM from Cesar_Philippidis@mentor.com ; Thu, 28 Jul 2016 21:21:30 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.224.2; Thu, 28 Jul 2016 21:21:30 -0700 From: Cesar Philippidis Subject: [gomp4] Fix PR72741 To: "gcc-patches@gcc.gnu.org" , Fortran List Message-ID: <579AD9C9.3030804@codesourcery.com> Date: Fri, 29 Jul 2016 04:21:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080807010502060007060805" X-SW-Source: 2016-07/txt/msg01910.txt.bz2 --------------080807010502060007060805 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-length: 708 Thomas found a bug in the fortran routine parser where errors involving invalid combinations of gang, worker, vector and seq clauses were getting suppressed. This patch does two things: 1) It moves the error handling into gfc_match_oacc_routine. So now gfc_oacc_routine_dims returns OACC_FUNCTION_NONE when it detects an error. That's fine because it's ok for routines to default to OACC_FUNCTION_SEQ. 2) It makes gfc_match_oacc_routine return a MATCH_ERROR when an error has been detected in gfc_oacc_routine_dims. This bug is also present in trunk, but I'd like to see my other fortran module patch go in first. In the meantime, I'll commit this patch to gomp-4_0-branch. Cesar --------------080807010502060007060805 Content-Type: text/x-patch; name="gomp4-pr72741.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gomp4-pr72741.diff" Content-length: 3023 2016-07-28 Cesar Philippidis PR fortran/72741 gcc/fortran/ * openmp.c (gfc_oacc_routine_dims): Move gfc_error to gfc_match_oacc_routine. Return OACC_FUNCTION_NONE on error. (gfc_match_oacc_routine): Call gfc_oacc_routine_dims for all routines directives. Propagate error as appropriate. gcc/testsuite/ * gfortran.dg/goacc/pr72741.f90: New test. diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index c20a0a3..3c39836 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -1877,7 +1877,8 @@ gfc_match_oacc_cache (void) return MATCH_YES; } -/* Determine the loop level for a routine. */ +/* Determine the loop level for a routine. Returns OACC_FUNCTION_NONE if + any error is detected. */ static oacc_function gfc_oacc_routine_dims (gfc_omp_clauses *clauses) @@ -1908,7 +1909,7 @@ gfc_oacc_routine_dims (gfc_omp_clauses *clauses) level = GOMP_DIM_MAX, mask |= GOMP_DIM_MASK (level); if (mask != (mask & -mask)) - gfc_error ("Multiple loop axes specified for routine"); + ret = OACC_FUNCTION_NONE; } return ret; @@ -1923,6 +1924,7 @@ gfc_match_oacc_routine (void) gfc_omp_clauses *c = NULL; gfc_oacc_routine_name *n = NULL; gfc_intrinsic_sym *isym = NULL; + oacc_function dims = OACC_FUNCTION_NONE; old_loc = gfc_current_locus; @@ -1991,6 +1993,14 @@ gfc_match_oacc_routine (void) != MATCH_YES)) return MATCH_ERROR; + dims = gfc_oacc_routine_dims (c); + if (dims == OACC_FUNCTION_NONE) + { + gfc_error ("Multiple loop axes specified for routine %C"); + gfc_current_locus = old_loc; + return MATCH_ERROR; + } + if (isym != NULL) /* There is nothing to do for intrinsic procedures. */ ; @@ -2011,8 +2021,7 @@ gfc_match_oacc_routine (void) gfc_current_ns->proc_name->name, &old_loc)) goto cleanup; - gfc_current_ns->proc_name->attr.oacc_function - = gfc_oacc_routine_dims (c); + gfc_current_ns->proc_name->attr.oacc_function = dims; gfc_current_ns->proc_name->attr.oacc_function_nohost = c ? c->nohost : false; } diff --git a/gcc/testsuite/gfortran.dg/goacc/pr72741.f90 b/gcc/testsuite/gfortran.dg/goacc/pr72741.f90 new file mode 100644 index 0000000..cf89727 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr72741.f90 @@ -0,0 +1,28 @@ +SUBROUTINE v_1 + !$ACC ROUTINE VECTOR WORKER ! { dg-error "Multiple loop axes" } +END SUBROUTINE v_1 + +SUBROUTINE sub_1 + IMPLICIT NONE + EXTERNAL :: g_1 + !$ACC ROUTINE (g_1) GANG WORKER ! { dg-error "Multiple loop axes" } + !$ACC ROUTINE (ABORT) SEQ VECTOR ! { dg-error "Multiple loop axes" } + + CALL v_1 + CALL g_1 + CALL ABORT +END SUBROUTINE sub_1 + +MODULE m_w_1 + IMPLICIT NONE + EXTERNAL :: w_1 + !$ACC ROUTINE (w_1) WORKER SEQ ! { dg-error "Multiple loop axes" } + !$ACC ROUTINE (ABORT) VECTOR GANG ! { dg-error "Multiple loop axes" } + +CONTAINS + SUBROUTINE sub_2 + CALL v_1 + CALL w_1 + CALL ABORT + END SUBROUTINE sub_2 +END MODULE m_w_1 --------------080807010502060007060805--