* [Patch, fortran] PR80554 [f08] variable redefinition in submodule
@ 2017-05-15 11:18 Paul Richard Thomas
2017-05-15 20:08 ` Steve Kargl
2017-05-15 20:31 ` Jerry DeLisle
0 siblings, 2 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2017-05-15 11:18 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
The attached bootstraps and regtests on FC23/x86_64 - OK for trunk and
later for 7-branch?
The comment in the patch and the ChangeLog are sufficiently clear that
no further explanation is needed here.
Cheers
Paul
2017-05-15 Paul Thomas <pault@gcc.gnu.org>
PR fortran/80554
* decl.c (build_sym): In a submodule allow overriding of host
associated symbols from the ancestor module with a new
declaration.
2017-05-15 Paul Thomas <pault@gcc.gnu.org>
PR fortran/80554
* gfortran.dg/submodule_29.f08: New test.
[-- Attachment #2: submit.diff --]
[-- Type: text/plain, Size: 3062 bytes --]
Index: gcc/fortran/decl.c
===================================================================
*** gcc/fortran/decl.c (revision 246951)
--- gcc/fortran/decl.c (working copy)
*************** build_sym (const char *name, gfc_charlen
*** 1383,1390 ****
symbol_attribute attr;
gfc_symbol *sym;
int upper;
! if (gfc_get_symbol (name, NULL, &sym))
return false;
/* Check if the name has already been defined as a type. The
--- 1383,1410 ----
symbol_attribute attr;
gfc_symbol *sym;
int upper;
+ gfc_symtree *st;
! /* Symbols in a submodule are host associated from the parent module or
! submodules. Therefore, they can be overridden by declarations in the
! submodule scope. Deal with this by attaching the existing symbol to
! a new symtree and recycling the old symtree with a new symbol... */
! st = gfc_find_symtree (gfc_current_ns->sym_root, name);
! if (st != NULL && gfc_state_stack->state == COMP_SUBMODULE
! && st->n.sym != NULL
! && st->n.sym->attr.host_assoc && st->n.sym->attr.used_in_submodule)
! {
! gfc_symtree *s = gfc_get_unique_symtree (gfc_current_ns);
! s->n.sym = st->n.sym;
! sym = gfc_new_symbol (name, gfc_current_ns);
!
!
! st->n.sym = sym;
! sym->refs++;
! gfc_set_sym_referenced (sym);
! }
! /* ...Otherwise generate a new symtree and new symbol. */
! else if (gfc_get_symbol (name, NULL, &sym))
return false;
/* Check if the name has already been defined as a type. The
Index: gcc/testsuite/gfortran.dg/submodule_29.f08
===================================================================
*** gcc/testsuite/gfortran.dg/submodule_29.f08 (nonexistent)
--- gcc/testsuite/gfortran.dg/submodule_29.f08 (working copy)
***************
*** 0 ****
--- 1,56 ----
+ ! { dg-do run }
+ !
+ ! Test the fix for PR80554 in which it was not recognised that the symbol 'i'
+ ! is host associated in the submodule 's' so that the new declaration in the
+ ! submodule was rejected.
+ !
+ ! Contributed by Tamas Bela Feher <tamas.bela.feher@ipp.mpg.de>
+ !
+ module M
+ implicit none
+ integer :: i = 0
+ character (100) :: buffer
+ interface
+ module subroutine write_i()
+ end subroutine
+ end interface
+ interface
+ module subroutine write_i_2()
+ end subroutine
+ end interface
+ contains
+ subroutine foo
+ integer :: i
+ end
+ end module
+
+ submodule (M) S
+ integer :: i = 137
+ contains
+ module subroutine write_i()
+ write (buffer,*) i
+ end subroutine
+ end submodule
+
+ submodule (M:S) S2
+ integer :: i = 1037
+ contains
+ module subroutine write_i_2()
+ write (buffer,*) i
+ end subroutine
+ end submodule
+
+ program test_submod_variable
+ use M
+ implicit none
+ integer :: j
+ i = 42
+ call write_i
+ read (buffer, *) j
+ if (i .ne. 42) call abort
+ if (j .ne. 137) call abort
+ call write_i_2
+ read (buffer, *) j
+ if (i .ne. 42) call abort
+ if (j .ne. 1037) call abort
+ end program
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran] PR80554 [f08] variable redefinition in submodule
2017-05-15 11:18 [Patch, fortran] PR80554 [f08] variable redefinition in submodule Paul Richard Thomas
@ 2017-05-15 20:08 ` Steve Kargl
2017-05-15 20:31 ` Jerry DeLisle
1 sibling, 0 replies; 4+ messages in thread
From: Steve Kargl @ 2017-05-15 20:08 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: fortran, gcc-patches
On Mon, May 15, 2017 at 12:10:42PM +0100, Paul Richard Thomas wrote:
> The attached bootstraps and regtests on FC23/x86_64 - OK for trunk and
> later for 7-branch?
>
> The comment in the patch and the ChangeLog are sufficiently clear that
> no further explanation is needed here.
>
> Cheers
>
> Paul
>
> 2017-05-15 Paul Thomas <pault@gcc.gnu.org>
>
> PR fortran/80554
> * decl.c (build_sym): In a submodule allow overriding of host
> associated symbols from the ancestor module with a new
> declaration.
>
> 2017-05-15 Paul Thomas <pault@gcc.gnu.org>
>
> PR fortran/80554
> * gfortran.dg/submodule_29.f08: New test.
OK.
--
Steve
20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4
20161221 https://www.youtube.com/watch?v=IbCHE-hONow
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran] PR80554 [f08] variable redefinition in submodule
2017-05-15 11:18 [Patch, fortran] PR80554 [f08] variable redefinition in submodule Paul Richard Thomas
2017-05-15 20:08 ` Steve Kargl
@ 2017-05-15 20:31 ` Jerry DeLisle
2017-05-16 20:33 ` Paul Richard Thomas
1 sibling, 1 reply; 4+ messages in thread
From: Jerry DeLisle @ 2017-05-15 20:31 UTC (permalink / raw)
To: Paul Richard Thomas, fortran, gcc-patches
On 05/15/2017 04:10 AM, Paul Richard Thomas wrote:
> The attached bootstraps and regtests on FC23/x86_64 - OK for trunk and
> later for 7-branch?
>
> The comment in the patch and the ChangeLog are sufficiently clear that
> no further explanation is needed here.
>
Looks OK Paul, thanks,
Jerry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, fortran] PR80554 [f08] variable redefinition in submodule
2017-05-15 20:31 ` Jerry DeLisle
@ 2017-05-16 20:33 ` Paul Richard Thomas
0 siblings, 0 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2017-05-16 20:33 UTC (permalink / raw)
To: Jerry DeLisle, Steve Kargl; +Cc: fortran, gcc-patches
Hi Jerry and Steve,
Thanks for taking a peek - committed as revision 248129.
I'll commit to 7-branch in a couple of weeks.
Cheers
Paul
On 15 May 2017 at 21:29, Jerry DeLisle <jvdelisle@charter.net> wrote:
> On 05/15/2017 04:10 AM, Paul Richard Thomas wrote:
>>
>> The attached bootstraps and regtests on FC23/x86_64 - OK for trunk and
>> later for 7-branch?
>>
>> The comment in the patch and the ChangeLog are sufficiently clear that
>> no further explanation is needed here.
>>
>
> Looks OK Paul, thanks,
>
> Jerry
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-16 20:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15 11:18 [Patch, fortran] PR80554 [f08] variable redefinition in submodule Paul Richard Thomas
2017-05-15 20:08 ` Steve Kargl
2017-05-15 20:31 ` Jerry DeLisle
2017-05-16 20:33 ` 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).