public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/102240] New: [F03] derived type parameter does not shadow variable name in enclosing scope
@ 2021-09-08 12:39 roland_wirth at web dot de
  2021-09-08 18:02 ` [Bug fortran/102240] [PDT] " anlauf at gcc dot gnu.org
  2023-06-30  8:24 ` pault at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: roland_wirth at web dot de @ 2021-09-08 12:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102240
           Summary: [F03] derived type parameter does not shadow variable
                    name in enclosing scope
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roland_wirth at web dot de
  Target Milestone: ---

Consider the following module definition:

    MODULE mo
    IMPLICIT NONE

    INTEGER :: n

    TYPE t(n)
      INTEGER, LEN :: n
      INTEGER :: a(n)
    END TYPE t
    END MODULE

gfortran 9.1.0 produces the following error when trying to compile:

        8 |     INTEGER :: a(n)
          |                 1
    Error: Variable 'n' at (1) in this context must be constant

Upon renaming the INTEGER variable to some other name `nn` the unit compiles
fine.

The Fortran 2003 standard (N1601) says in the Host association section
[16.4.1.3] that "A name that appears in the scoping unit as [...] (3) A
type-param-name in a derived-type-stmt [...] is a local identifier in the
scoping unit and any entity of the host that has this as its nongeneric name is
inaccessible by that name by host association." If I read that correctly the
type parameter `n` shadows the variable `n`, and the module definition should
be valid Fortran.

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

* [Bug fortran/102240] [PDT] derived type parameter does not shadow variable name in enclosing scope
  2021-09-08 12:39 [Bug fortran/102240] New: [F03] derived type parameter does not shadow variable name in enclosing scope roland_wirth at web dot de
@ 2021-09-08 18:02 ` anlauf at gcc dot gnu.org
  2023-06-30  8:24 ` pault at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-09-08 18:02 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-09-08
     Ever confirmed|0                           |1
            Summary|[F03] derived type          |[PDT] derived type
                   |parameter does not shadow   |parameter does not shadow
                   |variable name in enclosing  |variable name in enclosing
                   |scope                       |scope
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.

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

* [Bug fortran/102240] [PDT] derived type parameter does not shadow variable name in enclosing scope
  2021-09-08 12:39 [Bug fortran/102240] New: [F03] derived type parameter does not shadow variable name in enclosing scope roland_wirth at web dot de
  2021-09-08 18:02 ` [Bug fortran/102240] [PDT] " anlauf at gcc dot gnu.org
@ 2023-06-30  8:24 ` pault at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pault at gcc dot gnu.org @ 2023-06-30  8:24 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |82173
                 CC|                            |pault at gcc dot gnu.org

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Added to PDT meta-bug


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82173
[Bug 82173] [meta-bug] [PDT] Parameterized derived type errors

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

end of thread, other threads:[~2023-06-30  8:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08 12:39 [Bug fortran/102240] New: [F03] derived type parameter does not shadow variable name in enclosing scope roland_wirth at web dot de
2021-09-08 18:02 ` [Bug fortran/102240] [PDT] " anlauf at gcc dot gnu.org
2023-06-30  8:24 ` pault at gcc dot gnu.org

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