public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR69498 Fix ICE on unexpected submodule
@ 2017-03-25 21:34 Nicolas Koenig
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Koenig @ 2017-03-25 21:34 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 528 bytes --]

Hello everyone,

this fixes the ICE. The problem was a discrepancy between the name of 
the submodules symbol and the name of its symtree node.

Nicolas

2017-03-18  Nicolas Koenig  <koenigni@student.ethz.ch>
                 PR fortran/69498
                 * symbol.c (gfc_delete_symtree): If there is a period 
in the name, ignore
                 everything before it.

2017-03-18  Nicolas Koenig  <koenigni@student.ethz.ch>
                 PR fortran/69498
                 * gfortran.dg/submodule_unexp.f90: New test




[-- Attachment #2: p2.diff --]
[-- Type: text/x-patch, Size: 718 bytes --]

Index: symbol.c
===================================================================
--- symbol.c	(Revision 246320)
+++ symbol.c	(Arbeitskopie)
@@ -2782,10 +2782,20 @@ void
 gfc_delete_symtree (gfc_symtree **root, const char *name)
 {
   gfc_symtree st, *st0;
+  const char *p;
 
-  st0 = gfc_find_symtree (*root, name);
+  /* Submodules are marked as mod.submod.  When freeing a submodule
+     symbol, the symtree only has "submod", so adjust that here.  */
 
-  st.name = gfc_get_string ("%s", name);
+  p = strchr(name, '.');
+  if (p)
+    p++;
+  else
+    p = name;
+
+  st0 = gfc_find_symtree (*root, p);
+
+  st.name = gfc_get_string ("%s", p);
   gfc_delete_bbt (root, &st, compare_symtree);
 
   free (st0);

[-- Attachment #3: submodule_unexp.f90 --]
[-- Type: text/x-fortran, Size: 165 bytes --]

! { dg-do compile }
! PR fortran/69498
! This used to ICE
program p
   type t
   submodule (m) sm ! { dg-error "Unexpected SUBMODULE statement at" }
   end type
end

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, fortran] PR69498 Fix ICE on unexpected submodule
  2017-03-26 11:45 Dominique d'Humières
@ 2017-03-26 22:06 ` Thomas Koenig
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Koenig @ 2017-03-26 22:06 UTC (permalink / raw)
  To: Dominique d'Humières, koenigni
  Cc: Paul Richard Thomas, GCC-Fortran-ML, GCC-Patches-ML

Hi Dominique,

> A long time ago Paul sent me the following patch that fixes
> all three submodule ICEs in pr69498

Got any more patches like that?  If so, could you maybe attach
them to the relevant PRs?  Even if such patches should turn out not to
be perfect, they could still help.

Regarding the patch: I think it makes sense to fix the problem that
Nicolas discovered (the problem on freeing caused by the mismatch
between symtree and symbol name), even if the error is no longer
exposed due to the other patch.

Regards

	Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, fortran] PR69498 Fix ICE on unexpected submodule
@ 2017-03-26 11:45 Dominique d'Humières
  2017-03-26 22:06 ` Thomas Koenig
  0 siblings, 1 reply; 3+ messages in thread
From: Dominique d'Humières @ 2017-03-26 11:45 UTC (permalink / raw)
  To: koenigni; +Cc: Paul Richard Thomas, GCC-Fortran-ML, GCC-Patches-ML

Dear Nicolas,

A long time ago Paul sent me the following patch that fixes all three submodule ICEs in pr69498

Index: gcc/fortran/module.c
===================================================================
*** gcc/fortran/module.c	(revision 236994)
--- gcc/fortran/module.c	(working copy)
*************** gfc_match_submodule (void)
*** 744,749 ****
--- 744,756 ----
    if (!gfc_notify_std (GFC_STD_F2008, "SUBMODULE declaration at %C"))
      return MATCH_ERROR;
  
+   if (gfc_current_state () != COMP_NONE)
+     {
+       gfc_error ("SUBMODULE declaration at %C cannot appear within "
+ 		 "another scoping unit");
+       return MATCH_ERROR;
+     }
+ 
    gfc_new_block = NULL;
    gcc_assert (module_list == NULL);
  
Cheers,

Dominique

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-26 22:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-25 21:34 [Patch, fortran] PR69498 Fix ICE on unexpected submodule Nicolas Koenig
2017-03-26 11:45 Dominique d'Humières
2017-03-26 22:06 ` Thomas Koenig

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).