public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR33550 - ICE (segfault) when USEing ambiguous symbols
@ 2007-09-30 17:30 Paul Richard Thomas
  2007-09-30 21:49 ` Jerry DeLisle
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2007-09-30 17:30 UTC (permalink / raw)
  To: fortran, gcc-patches List

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

:ADDPATCH fortran:

This annoying bug emerged from the woodwork in discussion of PR33542
on comp.lang.fortran

Thanks to James Buskirk for pointing it out and to Tobias Burnus for posting it.

The fix is utterly trivial.  It bootstraps and regtests on
x86_ia64/fc5 - OK for trunk?

Paul

-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

[-- Attachment #2: Change.Logs --]
[-- Type: application/octet-stream, Size: 294 bytes --]

2007-09-30  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/33550
	* decl.c (get_proc_name): Return rc if rc is non-zero; ie. if
	the name is a reference to an ambiguous symbol.

2007-09-30  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/33550
	* gfortran.dg/ambiguous_reference_1.f90: New test.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: submit.diff --]
[-- Type: text/x-patch; name="submit.diff", Size: 1904 bytes --]

Index: /svn/trunk/gcc/fortran/decl.c
===================================================================
--- /svn/trunk/gcc/fortran/decl.c	(revision 128873)
+++ /svn/trunk/gcc/fortran/decl.c	(working copy)
@@ -669,7 +669,7 @@
 {
   gfc_symtree *st;
   gfc_symbol *sym;
-  int rc;
+  int rc = 0;
 
   /* Module functions have to be left in their own namespace because
      they have potentially (almost certainly!) already been referenced.
@@ -706,6 +706,9 @@
   else
     rc = gfc_get_symbol (name, gfc_current_ns->parent, result);
 
+  if (rc)
+    return rc;
+
   sym = *result;
   gfc_current_ns->refs++;
 
Index: /svn/trunk/gcc/testsuite/gfortran.dg/ambiguous_reference_1.f90
===================================================================
--- /svn/trunk/gcc/testsuite/gfortran.dg/ambiguous_reference_1.f90	(revision 0)
+++ /svn/trunk/gcc/testsuite/gfortran.dg/ambiguous_reference_1.f90	(revision 0)
@@ -0,0 +1,50 @@
+! { dg-do compile }
+! Tests the fix for PR33550, in which an ICE would occur, instead of
+! the abiguous reference error.
+!
+! Found at
+! http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/1abc1549a6a164f1/
+! by James Van Buskirk:
+!
+module M1
+   real x
+end module M1
+
+module M2
+   contains
+      subroutine y
+      end subroutine y
+end module M2
+
+module M3
+   use M2, x => y
+end module M3
+
+module M4
+   use M1
+   use M3
+end module M4
+
+module M5
+   use M4             ! 'x' is ambiguous here but is not referred to
+end module M5
+
+module M6
+   use M5             ! ditto
+end module M6
+
+program test
+   use M1
+   use M3
+   interface
+      function x(z)   ! { dg-error "ambiguous reference" }
+      end function x  ! { dg-error "Expecting END INTERFACE" }
+   end interface
+
+   write(*,*) 'Hello, world!'
+end program test
+
+function x(z)
+   x = z
+end function x
+! { dg-final { cleanup-modules "m1 m2 m3 m4 m5 m6" } }

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

* Re: [Patch, fortran] PR33550 - ICE (segfault) when USEing ambiguous  symbols
  2007-09-30 17:30 [Patch, fortran] PR33550 - ICE (segfault) when USEing ambiguous symbols Paul Richard Thomas
@ 2007-09-30 21:49 ` Jerry DeLisle
  2007-10-01  8:50   ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Jerry DeLisle @ 2007-09-30 21:49 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: fortran, gcc-patches List

Paul Richard Thomas wrote:
> :ADDPATCH fortran:
> 
> This annoying bug emerged from the woodwork in discussion of PR33542
> on comp.lang.fortran
> 
> Thanks to James Buskirk for pointing it out and to Tobias Burnus for posting it.
> 
> The fix is utterly trivial.  It bootstraps and regtests on
> x86_ia64/fc5 - OK for trunk?
> 
> Paul
> 
> 
OK, Obvious and simple rule.

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

* Re: [Patch, fortran] PR33550 - ICE (segfault) when USEing ambiguous symbols
  2007-09-30 21:49 ` Jerry DeLisle
@ 2007-10-01  8:50   ` Paul Richard Thomas
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Richard Thomas @ 2007-10-01  8:50 UTC (permalink / raw)
  To: Jerry DeLisle; +Cc: fortran, gcc-patches List

Thanks Jerry,

> OK, Obvious and simple rule.
>

Up to the "abiguous" that Tom Tromey pointed out.

Paul

-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

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

end of thread, other threads:[~2007-10-01  8:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-30 17:30 [Patch, fortran] PR33550 - ICE (segfault) when USEing ambiguous symbols Paul Richard Thomas
2007-09-30 21:49 ` Jerry DeLisle
2007-10-01  8:50   ` 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).