From patchwork Wed Oct 2 13:36:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Eggleston X-Patchwork-Id: 1170676 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-510067-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=codethink.co.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="wNfp26Vw"; 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 46jxyH63FHz9sCJ for ; Wed, 2 Oct 2019 23:37:11 +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 :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=tKAw9k8/lG/4+6wse 2Ph8deV4d7+cIy9P+Y8AHPkTEz07hXSwd85NlcCnuST8UP+9wJLyS1Rsx5Gh0E58 IxDeE+zIIVyUcVUVWQAfv3kkyR8QOU1FFxxdD73n2w6QQ3UaZmS+1pcAsPzAWUx2 HwGio1vROX20Khwh9PcdElht/0= 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 :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=ZPsPOnpHFj19kwh3iylaA9x V/Ls=; b=wNfp26VwnJML6HV3SramQxMax9hFAQoJrY7kN1qcDrPRv3rHyw1eXq1 pGXYRprc2h1OesL6PiwXGfpzBZlMYRq5x0RbY1kvr4zyOYfysRWDMLY6m5j0FILa F4MZn/a1MdXWA+6jRXYc5QpxZhL1eWu2XtYklEe+KdtbFm1GZJow= Received: (qmail 24940 invoked by alias); 2 Oct 2019 13:37:00 -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 24919 invoked by uid 89); 2 Oct 2019 13:37:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=UD:a.ne.b, UD:loc, fnoautomatic, AUTOMATIC X-HELO: imap1.codethink.co.uk Received: from imap1.codethink.co.uk (HELO imap1.codethink.co.uk) (176.9.8.82) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Oct 2019 13:36:57 +0000 Received: from [167.98.27.226] (helo=[10.35.5.11]) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1iFeoJ-00087G-JI; Wed, 02 Oct 2019 14:36:55 +0100 Subject: [PATCH, Fortran] Fix Automatics in equivalence test cases was Re: Automatics in Equivalences failures From: Mark Eggleston To: fortran , Tobias Burnus , gcc-patches References: <7f83f936-6722-01f3-01d1-5fd29c837c39@codethink.co.uk> <474399f2-c6ce-dbd1-dd1f-b47b33810d49@codethink.co.uk> Message-ID: Date: Wed, 2 Oct 2019 14:36:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <474399f2-c6ce-dbd1-dd1f-b47b33810d49@codethink.co.uk> Please find attached a patch to replace the test cases for "Automatic in equivalence". ChangeLog:     Mark Eggleston     * gfortran.dg/auto_in_equiv_1.f90: Deleted.     * gfortran.dg/auto_in_equiv_2.f90: Deleted.     * gfortran.dg/auto_in_equiv_3.f90: Deleted.     * gfortran.dg/automatics_in_equivalence_1.f90: New test.     * gfortran.dg/automatics_in_equivalence_2.f90: New test. OK to commit? regards, Mark On 30/09/2019 13:18, Mark Eggleston wrote: > > On 30/09/2019 10:06, Mark Eggleston wrote: >> Thanks to Tobias Burnius for fixing the dg directives in test cases. >> >> Now that the test cases for "Automatics in equivalence" (svn revision >> 274565) are actually being run, test failures are occurring. >> >> I've investigated the test failures for auto-in-equiv_3.f90: >> >> - -O1, -O2, -O3 and -Os fail >> - -O1 fails because the check of address fails due to a 40 byte >> difference in location of the stack >> - -O2, -O3 and -Os fail due the evaluation of an .and. operation >> returning .false. when both operands are .true.. >> >> The test case could be better and should probably be replaced with a >> better one. >> >> I've discovered that -finit-local-zero doesn't work if the local >> variable is in an equivalence statement where at least one the >> variables has an AUTOMATIC attribute. > On further investigation I find that local variables are not > initialised if the EQUIVALENCE attribute is set > (build_default_init_expr). So this is expected behaviour. So back to > the drawing board for a suitable test case. >> >> What is the best way of dealing with this? Reverting the commit and >> resubmitting a corrected patch when it's been fixed? >> >> regards, >> >> Mark >> >> From e461900f602b48e8d13402fca46d34506308785f Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Wed, 2 Oct 2019 10:23:49 +0100 Subject: [PATCH] Replace test cases for Automatics in equivalence --- gcc/testsuite/gfortran.dg/auto_in_equiv_1.f90 | 36 ------------- gcc/testsuite/gfortran.dg/auto_in_equiv_2.f90 | 38 ------------- gcc/testsuite/gfortran.dg/auto_in_equiv_3.f90 | 63 ---------------------- .../gfortran.dg/automatics_in_equivalence_1.f90 | 35 ++++++++++++ .../gfortran.dg/automatics_in_equivalence_2.f90 | 37 +++++++++++++ 5 files changed, 72 insertions(+), 137 deletions(-) delete mode 100644 gcc/testsuite/gfortran.dg/auto_in_equiv_1.f90 delete mode 100644 gcc/testsuite/gfortran.dg/auto_in_equiv_2.f90 delete mode 100644 gcc/testsuite/gfortran.dg/auto_in_equiv_3.f90 create mode 100644 gcc/testsuite/gfortran.dg/automatics_in_equivalence_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/automatics_in_equivalence_2.f90 diff --git a/gcc/testsuite/gfortran.dg/auto_in_equiv_1.f90 b/gcc/testsuite/gfortran.dg/auto_in_equiv_1.f90 deleted file mode 100644 index bf6e0c68a57..00000000000 --- a/gcc/testsuite/gfortran.dg/auto_in_equiv_1.f90 +++ /dev/null @@ -1,36 +0,0 @@ -! { dg-do compile } - -! Contributed by Mark Eggleston -program test - call suba(0) - call subb(0) - call suba(1) - -contains - subroutine suba(option) - integer, intent(in) :: option - integer, automatic :: a ! { dg-error "AUTOMATIC at \\(1\\) is a DEC extension" } - integer :: b - integer :: c - equivalence (a, b) - if (option.eq.0) then - ! initialise a and c - a = 9 - c = 99 - if (a.ne.b) stop 1 - if (loc(a).ne.loc(b)) stop 2 - else - ! a should've been overwritten - if (a.eq.9) stop 3 - end if - end subroutine suba - - subroutine subb(dummy) - integer, intent(in) :: dummy - integer, automatic :: x ! { dg-error "AUTOMATIC at \\(1\\) is a DEC extension" } - integer :: y - x = 77 - y = 7 - end subroutine subb - -end program test diff --git a/gcc/testsuite/gfortran.dg/auto_in_equiv_2.f90 b/gcc/testsuite/gfortran.dg/auto_in_equiv_2.f90 deleted file mode 100644 index e40c0f15f3e..00000000000 --- a/gcc/testsuite/gfortran.dg/auto_in_equiv_2.f90 +++ /dev/null @@ -1,38 +0,0 @@ -! { dg-do run } -! { dg-options "-fdec-static" } - -! Contributed by Mark Eggleston - -program test - call suba(0) - call subb(0) - call suba(1) - -contains - subroutine suba(option) - integer, intent(in) :: option - integer, automatic :: a - integer :: b - integer :: c - equivalence (a, b) - if (option.eq.0) then - ! initialise a and c - a = 9 - c = 99 - if (a.ne.b) stop 1 - if (loc(a).ne.loc(b)) stop 2 - else - ! a should've been overwritten - if (a.eq.9) stop 3 - end if - end subroutine suba - - subroutine subb(dummy) - integer, intent(in) :: dummy - integer, automatic :: x - integer :: y - x = 77 - y = 7 - end subroutine subb - -end program test diff --git a/gcc/testsuite/gfortran.dg/auto_in_equiv_3.f90 b/gcc/testsuite/gfortran.dg/auto_in_equiv_3.f90 deleted file mode 100644 index 57c384d1772..00000000000 --- a/gcc/testsuite/gfortran.dg/auto_in_equiv_3.f90 +++ /dev/null @@ -1,63 +0,0 @@ -! { dg-do run } -! { dg-options "-fdec-static -fno-automatic" } - -! Contributed by Mark Eggleston - -! Storage is NOT on the static unless explicitly specified using the -! DEC extension "automatic". The address of the first local variable -! is used to determine that storage for the automatic local variable -! is different to that of a local variable with no attributes. The -! contents of the local variable in suba should be overwritten by the -! call to subb. -! -program test - integer :: dummy - integer, parameter :: address = kind(loc(dummy)) - integer(address) :: ad1 - integer(address) :: ad2 - integer(address) :: ad3 - logical :: ok - - call suba(0, ad1) - call subb(0, ad2) - call suba(1, ad1) - call subc(0, ad3) - ok = (ad1.eq.ad3).and.(ad1.ne.ad2) - if (.not.ok) stop 4 - -contains - subroutine suba(option, addr) - integer, intent(in) :: option - integer(address), intent(out) :: addr - integer, automatic :: a - integer :: b - equivalence (a, b) - addr = loc(a) - if (option.eq.0) then - ! initialise a and c - a = 9 - if (a.ne.b) stop 1 - if (loc(a).ne.loc(b)) stop 2 - else - ! a should've been overwritten - if (a.eq.9) stop 3 - end if - end subroutine suba - - subroutine subb(dummy, addr) - integer, intent(in) :: dummy - integer(address), intent(out) :: addr - integer :: x - addr = loc(x) - x = 77 - end subroutine subb - - subroutine subc(dummy, addr) - integer, intent(in) :: dummy - integer(address), intent(out) :: addr - integer, automatic :: y - addr = loc(y) - y = 77 - end subroutine subc - -end program test diff --git a/gcc/testsuite/gfortran.dg/automatics_in_equivalence_1.f90 b/gcc/testsuite/gfortran.dg/automatics_in_equivalence_1.f90 new file mode 100644 index 00000000000..2791675af1b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/automatics_in_equivalence_1.f90 @@ -0,0 +1,35 @@ +! { dg-do run } +! { dg-options "-fdec-static -frecursive" } + +! Contributed by Mark Eggleston +! +! Check automatic variables can be used in equivalence statements. +! Any other variables that do not explicitly have the automatic +! attribute will be given the automatic attribute. +! +! Check that variables are on the stack by incorporating the +! equivalence in a recursive function. +! +program test + integer :: f + + f = factorial(5) + if (f.ne.120) stop 2 + +contains + function factorial(n) result(f) + integer :: f + integer, intent(in) :: n + integer, automatic :: a + integer :: b + equivalence (a,b) + + if (loc(a).ne.loc(b)) stop 1 + b = n + if (a.eq.1) then + f = 1 + else + f = a * factorial(b-1) + end if + end function +end program test diff --git a/gcc/testsuite/gfortran.dg/automatics_in_equivalence_2.f90 b/gcc/testsuite/gfortran.dg/automatics_in_equivalence_2.f90 new file mode 100644 index 00000000000..626db5835b8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/automatics_in_equivalence_2.f90 @@ -0,0 +1,37 @@ +! { dg-do run } +! { dg-options "-fdec-static -frecursive -fno-automatic" } + +! Contributed by Mark Eggleston +! +! Check automatic variables can be used in equivalence statements. +! Any other variables that do not explicitly have the automatic +! attribute will be given the automatic attribute. +! +! Check that variables are on the stack by incorporating the +! equivalence in a recursive function. +! +program test + integer :: f + + f = factorial(5) + if (f.ne.120) stop 2 + +contains + function factorial(n) result(f) + integer :: f + integer, intent(in) :: n + integer, automatic :: a + integer :: b + equivalence (a,b) + + if (loc(a).ne.loc(b)) stop 1 + b = n + if (a.eq.1) then + f = 1 + else + f = a * factorial(b-1) + end if + end function +end program test + +! { dg-warning "Flag '-fno-automatic' overwrites '-frecursive'" "warning" { target *-*-* } 0 } -- 2.11.0