Patchwork [fortran] PR50405 - Statement function with itself as argument SEGV's

login
register
mail settings
Submitter Tobias Burnus
Date May 27, 2013, 2:22 p.m.
Message ID <51A36C30.4080803@net-b.de>
Download mbox | patch
Permalink /patch/246609/
State New
Headers show

Comments

Tobias Burnus - May 27, 2013, 2:22 p.m.
Am 26.05.2013 05:58, schrieb Bud Davis:
> The changes suggested by:
> http://gcc.gnu.org/ml/fortran/2013-05/msg00057.html
> have been made in the below diff and test file.
>
> Could someone please commit this ?

I thought you have commit rights?

Note: You added a hyphen to the error message without changing the 
dg-error pattern. Additionally, it would help if you could also create a 
changelog for the testsuite - also a "*" was missing before the file 
name in the ChangeLog. And finally, I am not sure whether "!{ dg-do 
compile }" works - it might be that DejaGNU requires a space before the "{".

Committed as Rev. 199358 (with minor modifications). Thanks for the 
patch - and welcome back to contributing to gfortran :-)

Tobias

Patch

Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(Revision 199357)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,9 @@ 
+2013-05-27  Bud Davis  <jmdavis@link.com>
+
+	PR fortran/50405
+	* resolve.c (resolve_formal_arglist): Detect error when an argument
+	has the same name as the function.
+
 2013-05-27  Tobias Burnus  <burnus@net-b.de>
 
 	* expr.c (gfc_build_intrinsic_call): Make symbol as attr.artificial.
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(Revision 199357)
+++ gcc/fortran/resolve.c	(Arbeitskopie)
@@ -306,6 +306,14 @@  resolve_formal_arglist (gfc_symbol *proc)
 	       && !resolve_procedure_interface (sym))
 	return;
 
+      if (strcmp (proc->name, sym->name) == 0)
+        {
+          gfc_error ("Self-referential argument "
+                     "'%s' at %L is not allowed", sym->name,
+                     &proc->declared_at);
+          return;
+        }
+
       if (sym->attr.if_source != IFSRC_UNKNOWN)
 	resolve_formal_arglist (sym);
 
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(Revision 199357)
+++ gcc/testsuite/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,8 @@ 
+2013-05-27  Bud Davis  <jmdavis@link.com>
+
+	PR fortran/50405
+	* gfortran.dg/stfunc_8.f90: New.
+
 2013-05-27  Richard Biener  <rguenther@suse.de>
 
 	PR tree-optimization/57343
Index: gcc/testsuite/gfortran.dg/stfunc_8.f90
===================================================================
--- gcc/testsuite/gfortran.dg/stfunc_8.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/stfunc_8.f90	(Arbeitskopie)
@@ -0,0 +1,9 @@ 
+! { dg-do compile }
+! { dg-options "" }
+!
+! PR fortran/50405
+!
+! Submitted by zeccav@gmail.com
+!
+       f(f) = 0 ! { dg-error "Self-referential argument" }
+       end