* [PATCH, Fortran] fix EQUIVALENCE in MODULE issues
@ 2015-06-03 22:09 Steve Kargl
2015-06-04 8:25 ` FX
0 siblings, 1 reply; 3+ messages in thread
From: Steve Kargl @ 2015-06-03 22:09 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]
The attach patch fixes two issues with EQUIVALENCE statements
in modules.
The first issue was fixed by Russell Whitesides where an
EQUIVALENCE statement that is USEs associated into multiple
modules will appear multiple times in a new module if the
previous modules are USEd by the new module. Russell's
patch checks for duplicates and tosses extra instances.
His original patch is found here:
https://gcc.gnu.org/ml/fortran/2015-05/msg00073.html
A testcase is available in PR fortran/60780. That testcase
may be unsuitable for the testsuite.
The second issue involves nearly 9 year code (r113465), which
tries to eliminate unused equivalence-objects from an
equivalence-set if the user USEs an ONLY clause (see PR
fortran/66377). According to Dominique this issue goes back
to at least 4.3.1.
I have built trunk and regression tested the attached patch.
There are no regression caused by the patch. OK to commit?
PS: pault, the old code was written by you.
2015-06-03 Russell Whitesides <russelldub@gmail.com>
Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/40958
PR fortran/60780
PR fortran/66377
* module.c (load_equiv): Add check for loading duplicate EQUIVALENCEs
from different modules. Eliminate the pruning of unused
equivalence-objects
2015-06-03 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/66377
gfortran.dg/equiv_9.f90: New test.
--
Steve
[-- Attachment #2: equiv.diff --]
[-- Type: text/x-diff, Size: 2023 bytes --]
Index: fortran/module.c
===================================================================
--- fortran/module.c (revision 224098)
+++ fortran/module.c (working copy)
@@ -4479,8 +4479,8 @@ load_commons (void)
static void
load_equiv (void)
{
- gfc_equiv *head, *tail, *end, *eq;
- bool unused;
+ gfc_equiv *head, *tail, *end, *equiv;
+ bool unused, duplicate;
mio_lparen ();
in_load_equiv = true;
@@ -4507,23 +4507,19 @@ load_equiv (void)
mio_expr (&tail->expr);
}
- /* Unused equivalence members have a unique name. In addition, it
- must be checked that the symbols are from the same module. */
- unused = true;
- for (eq = head; eq; eq = eq->eq)
+ /* Check for duplicate equivalences being loaded from different modules */
+ duplicate = false;
+ for (equiv = gfc_current_ns->equiv; equiv; equiv = equiv->next)
{
- if (eq->expr->symtree->n.sym->module
- && head->expr->symtree->n.sym->module
- && strcmp (head->expr->symtree->n.sym->module,
- eq->expr->symtree->n.sym->module) == 0
- && !check_unique_name (eq->expr->symtree->name))
+ if (equiv->module && head->module
+ && strcmp (equiv->module, head->module) == 0)
{
- unused = false;
+ duplicate = true;
break;
}
}
- if (unused)
+ if (duplicate)
{
for (eq = head; eq; eq = head)
{
Index: testsuite/gfortran.dg/equiv_9.f90
===================================================================
--- testsuite/gfortran.dg/equiv_9.f90 (revision 0)
+++ testsuite/gfortran.dg/equiv_9.f90 (working copy)
@@ -0,0 +1,22 @@
+! { dg-do run }
+! PR fortran/66377
+!
+module constant
+ integer x1, x2, x3
+ integer x(3)
+ equivalence (x(1),x1), (x2,x(2)), (x3,x(3))
+end module
+
+program test
+ use constant
+ implicit none
+ x = (/1, 2, 3/)
+ call another()
+end program
+
+subroutine another()
+ use constant, only : x2
+ implicit none
+ if (x2 /= 2) call abort
+end subroutine
+! { dg-final { cleanup-modules "constant" } }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH, Fortran] fix EQUIVALENCE in MODULE issues
2015-06-03 22:09 [PATCH, Fortran] fix EQUIVALENCE in MODULE issues Steve Kargl
@ 2015-06-04 8:25 ` FX
2015-06-04 10:39 ` Paul Richard Thomas
0 siblings, 1 reply; 3+ messages in thread
From: FX @ 2015-06-04 8:25 UTC (permalink / raw)
To: Steve Kargl; +Cc: fortran, gcc-patches
> 2015-06-03 Russell Whitesides <russelldub@gmail.com>
> Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/40958
> PR fortran/60780
> PR fortran/66377
> * module.c (load_equiv): Add check for loading duplicate EQUIVALENCEs
> from different modules. Eliminate the pruning of unused
> equivalence-objects
>
>
> 2015-06-03 Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/66377
> gfortran.dg/equiv_9.f90: New test.
OK. I agree the other test case is not suitable for the testsuite.
FX
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH, Fortran] fix EQUIVALENCE in MODULE issues
2015-06-04 8:25 ` FX
@ 2015-06-04 10:39 ` Paul Richard Thomas
0 siblings, 0 replies; 3+ messages in thread
From: Paul Richard Thomas @ 2015-06-04 10:39 UTC (permalink / raw)
To: FX; +Cc: Steve Kargl, fortran, gcc-patches
Hi Steve,
The patch did last from gcc-4.2, apparently without anybody detecting
a problem :-)
Anyway, the patch looks good to me too. Thanks for getting to it so fast, FX.
Cheers
Paul
On 4 June 2015 at 10:24, FX <fxcoudert@gmail.com> wrote:
>
>> 2015-06-03 Russell Whitesides <russelldub@gmail.com>
>> Steven G. Kargl <kargl@gcc.gnu.org>
>>
>> PR fortran/40958
>> PR fortran/60780
>> PR fortran/66377
>> * module.c (load_equiv): Add check for loading duplicate EQUIVALENCEs
>> from different modules. Eliminate the pruning of unused
>> equivalence-objects
>>
>>
>> 2015-06-03 Steven G. Kargl <kargl@gcc.gnu.org>
>>
>> PR fortran/66377
>> gfortran.dg/equiv_9.f90: New test.
>
>
> OK. I agree the other test case is not suitable for the testsuite.
>
> FX
--
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.
Groucho Marx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-04 10:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-03 22:09 [PATCH, Fortran] fix EQUIVALENCE in MODULE issues Steve Kargl
2015-06-04 8:25 ` FX
2015-06-04 10:39 ` Paul Richard Thomas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).