From patchwork Sat Jul 13 23:54:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 1131665 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-505058-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=charter.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="MfILpUlf"; 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 45mRTz5ZGhz9sDB for ; Sun, 14 Jul 2019 09:54:24 +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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=rBLiBv9T8bLvzXjW+LaUQMxmO3pui7UPm44iLyZkg9dJdBbQNG tPI1SqMs1swfjD7bb1K3FVX1s5YNmIuTQYegoZrw0kVIhNc5euc/7gJ7VP09fSbK uVLHWFBeJK0GQ7PJ7ULOLI2XzsK6R5c/Pp6OlJPxd+1yIeb2DzlQc/RWM= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=wlZhM59FcXOTpa+PYSVGyu2/ZyQ=; b=MfILpUlf4fZe7NpNUsxD 1R97d5pyiwR9RViz9vMAHmYIwP0SSzuX2SRIbaQZCLJ3wlvTr3uWsrCqZGF8tzIi 47J0YumIoUzSuJzBpFFx8hpDdJVdhQlPUCHTlnFyKGi7ib7NM2I7QwHwP80fmmZs NHjESWrGV1SoN88p4Za0YRQ= Received: (qmail 11562 invoked by alias); 13 Jul 2019 23:54:12 -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 11547 invoked by uid 89); 13 Jul 2019 23:54:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=H*Ad:U*jvdelisle, H*M:charter, Jerry, jerry X-HELO: impout009.msg.chrl.nc.charter.net Received: from impout009aa.msg.chrl.nc.charter.net (HELO impout009.msg.chrl.nc.charter.net) (47.43.20.33) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 13 Jul 2019 23:54:11 +0000 Received: from [192.168.1.6] ([66.191.41.128]) by cmsmtp with ESMTPA id mRqChGYzQiYmumRqChkMMl; Sat, 13 Jul 2019 23:54:09 +0000 Authentication-Results: charter.net; none To: "fortran@gcc.gnu.org" Cc: GCC Patches From: Jerry DeLisle Subject: [patch, fortran] Pr87233 Constraint C1279 still followed after f2008 standard revision Message-ID: Date: Sat, 13 Jul 2019 16:54:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Hi all, The attached patch removes the subject constraint for gfortran default and -std=f2008/f2018. I had issues with repetitious errors. I tried to get rid of it using the e->error = 1 method useded later in the function, but that did not work, so I resorted to gfc_error_now which does the job. Also modified one test case and added a new to cover this in the testsuite. Regression tested on x86_64-pc-linux-gnu. OK for trunk? Regards, Jerry 2019-07-13 Jerry DeLisle PR fortran/87233 * expr.c (check_restricted): Relax constraint C1279 which was removed from F2008 and above. and 2019-07-13 Jerry DeLisle PR fortran/87233 * gfortran.dg/initialization_14.f90: Modify to now pass by remiving two dg-error commands. Added comments. * gfortran.dg/initialization_30.f90: New test that includes the two tests removed above with the 'dg-options -std=f95'. diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index ec9e3288b48..3b64b196c1b 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3305,11 +3305,13 @@ check_restricted (gfc_expr *e) restricted expression in an elemental procedure, it will have already been simplified away once we get here. Therefore we don't need to jump through hoops to distinguish valid from - invalid cases. */ - if (sym->attr.dummy && sym->ns == gfc_current_ns + invalid cases. Allowed in F2018. */ + if (gfc_notification_std (GFC_STD_F2008) + && sym->attr.dummy && sym->ns == gfc_current_ns && sym->ns->proc_name && sym->ns->proc_name->attr.elemental) { - gfc_error ("Dummy argument %qs not allowed in expression at %L", + gfc_error_now ("Dummy argument %qs not " + "allowed in expression at %L", sym->name, &e->where); break; } diff --git a/gcc/testsuite/gfortran.dg/initialization_14.f90 b/gcc/testsuite/gfortran.dg/initialization_14.f90 index 4d5b6856cf0..aa1437719ac 100644 --- a/gcc/testsuite/gfortran.dg/initialization_14.f90 +++ b/gcc/testsuite/gfortran.dg/initialization_14.f90 @@ -3,18 +3,18 @@ ! Dummy arguments are disallowed in initialization expressions in ! elemental functions except as arguments to the intrinsic functions ! BIT_SIZE, KIND, LEN, or to the numeric inquiry functions listed -! in 13.11.8 +! in 13.11.8 F95, likewise not allowed in F2003, now allowed in F2008. MODULE TT INTEGER M CONTAINS ELEMENTAL REAL FUNCTION two(N) INTEGER, INTENT(IN) :: N - INTEGER, DIMENSION(N) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" } + INTEGER, DIMENSION(N) :: scr ! Now valid under F2008 END FUNCTION ELEMENTAL REAL FUNCTION twopointfive(N) INTEGER, INTENT(IN) :: N - INTEGER, DIMENSION(MAX(N,2)) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" } + INTEGER, DIMENSION(MAX(N,2)) :: scr ! Now valid under F2008 end FUNCTION twopointfive REAL FUNCTION three(N) diff --git a/gcc/testsuite/gfortran.dg/initialization_30.f90 b/gcc/testsuite/gfortran.dg/initialization_30.f90 new file mode 100644 index 00000000000..ff8436bc7c9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/initialization_30.f90 @@ -0,0 +1,21 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +! PR 20851 +! Dummy arguments are disallowed in initialization expressions in +! elemental functions except as arguments to the intrinsic functions +! BIT_SIZE, KIND, LEN, or to the numeric inquiry functions listed +! in 13.11.8 +MODULE TT +INTEGER M +CONTAINS + ELEMENTAL REAL FUNCTION two(N) + INTEGER, INTENT(IN) :: N + INTEGER, DIMENSION(N) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" } + END FUNCTION + + ELEMENTAL REAL FUNCTION twopointfive(N) + INTEGER, INTENT(IN) :: N + INTEGER, DIMENSION(MAX(N,2)) :: scr ! { dg-error "Dummy argument 'n' not allowed in expression" } + end FUNCTION twopointfive +END MODULE +END