diff mbox

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

Message ID 1368760968.56247.YahooMailClassic@web182202.mail.bf1.yahoo.com
State New
Headers show

Commit Message

Bud Davis May 17, 2013, 3:22 a.m. UTC
Not to much to add beyond the title and the patch.
The test file fails before (eventually, when you run out of stack) and passes after the patch is applied.  No new testsuite failures.


--bud



!{ dg-do compile }
! submitted by zeccav@gmail.com
!{ dg-prune-output "Obsolescent feature: Statement function at" }
       f(f) = 0 ! { dg-error "Self referential argument" }
       end

 

2013-05-17  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.

Comments

Tobias Burnus May 17, 2013, 7:19 a.m. UTC | #1
Am 17.05.2013 05:22, schrieb Bud Davis:
> Not to much to add beyond the title and the patch.
> The test file fails before (eventually, when you run out of stack) and passes after the patch is applied.  No new testsuite failures.
>
>
> --bud
>
> Index: gcc/gcc/fortran/resolve.c
> ===================================================================
> --- gcc/gcc/fortran/resolve.c    (revision 198955)
> +++ gcc/gcc/fortran/resolve.c    (working copy)
> @@ -306,6 +306,14 @@
>              && !resolve_procedure_interface (sym))
>       return;
>   
> +      if (strcmp (proc->name,sym->name) == 0)

Missing blank after the comma.

> +        {
> +       gfc_error ("Self referential argument "
> +       "'%s' at %L is not allowed", sym->name,
> +       &proc->declared_at);
> +       return;

Indentation is wrong. (As a friend of hyphens, I would add one between 
self and referential, but it is also fine without.)

> !{ dg-do compile }
> ! submitted by zeccav@gmail.com
> !{ dg-prune-output "Obsolescent feature: Statement function at" }

Please add "! PR fortran/50405" as comment.

Instead of dg-prune-output,  you could also use: '! { dg-options "" }'. 
That will override the default setting, i.e. it removes the "-pedantic".

>         f(f) = 0 ! { dg-error "Self referential argument" }
>         end
>
> 2013-05-17  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.

OK and thanks for the patch!

Tobias

PS: Nice that you are back to (casual) gfortran development.
diff mbox

Patch

Index: gcc/gcc/fortran/resolve.c
===================================================================
--- gcc/gcc/fortran/resolve.c    (revision 198955)
+++ gcc/gcc/fortran/resolve.c    (working copy)
@@ -306,6 +306,14 @@ 
            && !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);