From patchwork Wed Jun 13 14:06:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cesar Philippidis X-Patchwork-Id: 928896 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-479636-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mentor.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="BcYwQe2u"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 415T8158f5z9s4Y for ; Thu, 14 Jun 2018 00:06:40 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=Sx71yazmTrBhxIo+yl+DlxP6hBqEwawIz2VHXvuOcqxLHfFkmT22A UxyIPOwlDuDCc2rwVhRtXlTWb11dbazZO++7lc5XokYMuBlGllTEALeCc2vuORui if1YcjRhV7xu5c4uc5gTIJv2tKQEXGDlToU3seO5/07pEEWP6z7lxw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=sKa8EarXOR3PxamG0/MP6VghPzU=; b=BcYwQe2uL56OisnJ7dFf veMNUNKgT1JfdcuumzZyfctc+Wh+6k4GxmecPzR40ZnpMuVneTxzzpklz+7OCgEC fPMPvruL/+1HPr4rX4mJ3HJE65AX6lL3/N8mh3TaGtv1oi+xTgrdxiBPhXsK4lPp HSakpZZR8oXhnpkXnhXwGHs= Received: (qmail 44686 invoked by alias); 13 Jun 2018 14:06:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 44668 invoked by uid 89); 13 Jun 2018 14:06:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=preform, H*r:0700 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 ESMTP; Wed, 13 Jun 2018 14:06:30 +0000 Received: from svr-orw-mbx-01.mgc.mentorg.com ([147.34.90.201]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1fT6Pq-0002eS-Rt from Cesar_Philippidis@mentor.com ; Wed, 13 Jun 2018 07:06:26 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-mbx-01.mgc.mentorg.com (147.34.90.201) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 13 Jun 2018 07:06:24 -0700 From: Cesar Philippidis Subject: [PATCH] handle OpenMP/OpenACC regions inside Fortran character functions (PR85703) To: "gcc-patches@gcc.gnu.org" , Fortran List , Jakub Jelinek Message-ID: <156e0ebd-08f7-4424-4899-386c571444c2@mentor.com> Date: Wed, 13 Jun 2018 07:06:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-orw-mbx-04.mgc.mentorg.com (147.34.90.204) To svr-orw-mbx-01.mgc.mentorg.com (147.34.90.201) Character variables in Fortran are slightly different than reals and integers because they can represent a single character or a string of them. Consequently, due their nature, the Fortran resolver requires more information to preform error checking on them. PR85703 exposed an ICE when an OpenACC or OpenMP region is nested inside a Fortran character function. I've isolated the problem down to the gfc_matching_function not being reset on entry to decode_oacc_directive or decode_omp_directive. Usually decode_statement resets that variable, but both OpenACC and OpenMP have their own statement decoders, and therein lies the problems. The fix is to reset gfc_matching_function early in those functions. Is this OK for trunk and GCC 8? Thanks, Cesar 2018-06-13 Cesar Philippidis PR fortran/85703 gcc/fortran/ * parse.c (decode_oacc_directive): Set gfc_matching_function to false. (decode_omp_directive): Likewise. gcc/testsuite/ * gfortran.dg/goacc/pr85703.f90: New test. * gfortran.dg/gomp/pr85703.f90: New test. From 8f763ee8aab252d1435cd0f5e32f8773722a69b1 Mon Sep 17 00:00:00 2001 From: Cesar Philippidis Date: Tue, 12 Jun 2018 10:32:16 -0700 Subject: [PATCH] fix pr85703 --- gcc/fortran/parse.c | 4 ++++ gcc/testsuite/gfortran.dg/goacc/pr85703.f90 | 9 +++++++++ gcc/testsuite/gfortran.dg/gomp/pr85703.f90 | 8 ++++++++ 3 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/goacc/pr85703.f90 create mode 100644 gcc/testsuite/gfortran.dg/gomp/pr85703.f90 diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index a3693a1..4ce6eb4 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -624,6 +624,8 @@ decode_oacc_directive (void) gfc_clear_error (); /* Clear any pending errors. */ gfc_clear_warning (); /* Clear any pending warnings. */ + gfc_matching_function = false; + if (gfc_pure (NULL)) { gfc_error_now ("OpenACC directives at %C may not appear in PURE " @@ -795,6 +797,8 @@ decode_omp_directive (void) gfc_clear_error (); /* Clear any pending errors. */ gfc_clear_warning (); /* Clear any pending warnings. */ + gfc_matching_function = false; + if (gfc_current_state () == COMP_FUNCTION && gfc_current_block ()->result->ts.kind == -1) spec_only = true; diff --git a/gcc/testsuite/gfortran.dg/goacc/pr85703.f90 b/gcc/testsuite/gfortran.dg/goacc/pr85703.f90 new file mode 100644 index 0000000..d9de1a3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr85703.f90 @@ -0,0 +1,9 @@ +! PR fortran/85703 +! { dg-do compile } + +character function f() + !$acc parallel loop reduction(+:a) + do i = 1, 4 + end do + !$acc end parallel loop +end diff --git a/gcc/testsuite/gfortran.dg/gomp/pr85703.f90 b/gcc/testsuite/gfortran.dg/gomp/pr85703.f90 new file mode 100644 index 0000000..7ca2b93 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr85703.f90 @@ -0,0 +1,8 @@ +! PR fortran/85703 +! { dg-do compile } + +character function f() + !$omp single + !$omp end single + f = 'a' +end -- 2.7.4