public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "roland_wirth at web dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/102240] New: [F03] derived type parameter does not shadow variable name in enclosing scope Date: Wed, 08 Sep 2021 12:39:43 +0000 [thread overview] Message-ID: <bug-102240-4@http.gcc.gnu.org/bugzilla/> (raw) 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.
next reply other threads:[~2021-09-08 12:39 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-08 12:39 roland_wirth at web dot de [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-102240-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).