public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/50525] New: gfortran should not allow early reference to entry dummy argument  (r178939)
@ 2011-09-26 10:32 zeccav at gmail dot com
  2011-09-27  8:24 ` [Bug fortran/50525] " burnus at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: zeccav at gmail dot com @ 2011-09-26 10:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50525

             Bug #: 50525
           Summary: gfortran should not allow early reference to entry
                    dummy argument  (r178939)
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zeccav@gmail.com


! gfortran should not allow early reference to entry dummy argument  (r178939) 
      subroutine sub
      f(y)=x ! this is wrong
      entry e(x)
      end


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

* [Bug fortran/50525] gfortran should not allow early reference to entry dummy argument  (r178939)
  2011-09-26 10:32 [Bug fortran/50525] New: gfortran should not allow early reference to entry dummy argument (r178939) zeccav at gmail dot com
@ 2011-09-27  8:24 ` burnus at gcc dot gnu.org
  2011-09-27 12:44 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-09-27  8:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50525

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-09-27 07:56:20 UTC ---
NAG has:

Error: test.f90, line 2: Dummy arg X used before first occurrence in an
argument list


And ifort has:

h4j.f90(2): error #6482: An ENTRY dummy argument is referenced in an executable
statement before it appears in any ENTRY statement.   [X]
      f(y)=x ! this is wrong
-----------^


The easiest fix is probably to check whether the symbol is already defined when
parsing "entry e(x)" (or adding attr.dummy).


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

* [Bug fortran/50525] gfortran should not allow early reference to entry dummy argument  (r178939)
  2011-09-26 10:32 [Bug fortran/50525] New: gfortran should not allow early reference to entry dummy argument (r178939) zeccav at gmail dot com
  2011-09-27  8:24 ` [Bug fortran/50525] " burnus at gcc dot gnu.org
@ 2011-09-27 12:44 ` burnus at gcc dot gnu.org
  2011-09-27 14:40 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-09-27 12:44 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50525

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-09-27 12:12:03 UTC ---
I meant something like the following. Though, the wording could be improved.

--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -4296,6 +4296,14 @@ gfc_match_formal_arglist (gfc_symbol *progname, int
st_flag, int null_flag)

          if (gfc_get_symbol (name, NULL, &sym))
            goto cleanup;
+
+         if (sym->attr.referenced && !sym->attr.dummy)
+           {
+             gfc_error ("Argument '%s' at %C has been already used at %L",
+                        sym->name, &sym->declared_at);
+             m = MATCH_ERROR;
+             goto cleanup;
+           }
        }

       p = gfc_get_formal_arglist ();


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

* [Bug fortran/50525] gfortran should not allow early reference to entry dummy argument  (r178939)
  2011-09-26 10:32 [Bug fortran/50525] New: gfortran should not allow early reference to entry dummy argument (r178939) zeccav at gmail dot com
  2011-09-27  8:24 ` [Bug fortran/50525] " burnus at gcc dot gnu.org
  2011-09-27 12:44 ` burnus at gcc dot gnu.org
@ 2011-09-27 14:40 ` burnus at gcc dot gnu.org
  2013-06-22 15:34 ` dominiq at lps dot ens.fr
  2021-02-27  9:43 ` zeccav at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-09-27 14:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50525

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-09-27 14:27:39 UTC ---
The patch causes regressions as it comes before the check in resolve_variable
(search for "before the ENTRY", which covers a similar issue (cf PR 25090).
Namely:
  gfortran.dg/entry_dummy_ref_1.f90
  gfortran.dg/entry_dummy_ref_2.f90

False positive - ("n" used in a specification expression):
  gfortran.dg/entry_array_specs_2.f

 * * *

From the F2008 standard ("12.6.2.6 ENTRY statement", para 7):
  "In a subprogram, a name that appears as a dummy argument in an ENTRY 
   statement shall not appear in an executable statement preceding that ENTRY 
   statement, unless it also appears in a FUNCTION, SUBROUTINE, or ENTRY 
   statement that precedes the executable statement."

 * * *

Regarding resolve_variable: As cs_base == NULL, the existing check

5086      /* Deal with forward references to entries during resolve_code, to
5087         satisfy, at least partially, 12.5.2.5.  */
5088      if (gfc_current_ns->entries
5089          && current_entry_id == sym->entry_id
5090          && cs_base

fails and, hence, there is no error.

 * * *

Side remarks:

a) "before the ENTRY statement in which it is a parameter"
-> Misuse of the term "parameter"

b) "warning: ‘master.0.sub’ defined but not used"
-> Declare as DECL_ARTIFICIAL to avoid warning - or to handle it better if the
warning itself makes sense.


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

* [Bug fortran/50525] gfortran should not allow early reference to entry dummy argument  (r178939)
  2011-09-26 10:32 [Bug fortran/50525] New: gfortran should not allow early reference to entry dummy argument (r178939) zeccav at gmail dot com
                   ` (2 preceding siblings ...)
  2011-09-27 14:40 ` burnus at gcc dot gnu.org
@ 2013-06-22 15:34 ` dominiq at lps dot ens.fr
  2021-02-27  9:43 ` zeccav at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-06-22 15:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50525

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-06-22
     Ever confirmed|0                           |1

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Still present at revision 200321.


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

* [Bug fortran/50525] gfortran should not allow early reference to entry dummy argument  (r178939)
  2011-09-26 10:32 [Bug fortran/50525] New: gfortran should not allow early reference to entry dummy argument (r178939) zeccav at gmail dot com
                   ` (3 preceding siblings ...)
  2013-06-22 15:34 ` dominiq at lps dot ens.fr
@ 2021-02-27  9:43 ` zeccav at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: zeccav at gmail dot com @ 2021-02-27  9:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50525

--- Comment #6 from Vittorio Zecca <zeccav at gmail dot com> ---
Still in trunk.

The NAG nagfor and Intel ifort compilers detect the issue.

ifort -S -w gfbug72.f
gfbug72.f(4): error #6482: An ENTRY dummy argument is referenced in an
executable statement before it appears in any ENTRY statement.   [X]
      f(y)=x ! this is wrong
-----------^
compilation aborted for gfbug72.f (code 1)

[vitti f95]$nagfor -S -w gfbug72.f
NAG Fortran Compiler Release 7.0(Yurakucho) Build 7042
Error: gfbug72.f, line 4: Dummy arg X used before first occurrence in an
argument list
[NAG Fortran Compiler error termination, 1 error]

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

end of thread, other threads:[~2021-02-27  9:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-26 10:32 [Bug fortran/50525] New: gfortran should not allow early reference to entry dummy argument (r178939) zeccav at gmail dot com
2011-09-27  8:24 ` [Bug fortran/50525] " burnus at gcc dot gnu.org
2011-09-27 12:44 ` burnus at gcc dot gnu.org
2011-09-27 14:40 ` burnus at gcc dot gnu.org
2013-06-22 15:34 ` dominiq at lps dot ens.fr
2021-02-27  9:43 ` zeccav at gmail dot com

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