public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-7003] Fortran: reject module variable as character length in PARAMETER [PR104349] Date: Tue, 4 Apr 2023 16:50:21 +0000 (GMT) [thread overview] Message-ID: <20230404165021.0ABCB3858C54@sourceware.org> (raw) https://gcc.gnu.org/g:c57a93f647511cf7a3005f1197a1da03b5e3a1b0 commit r13-7003-gc57a93f647511cf7a3005f1197a1da03b5e3a1b0 Author: Harald Anlauf <anlauf@gmx.de> Date: Mon Apr 3 21:34:01 2023 +0200 Fortran: reject module variable as character length in PARAMETER [PR104349] gcc/fortran/ChangeLog: PR fortran/104349 * expr.cc (check_restricted): Adjust check for valid variables in restricted expressions: make no exception for module variables. gcc/testsuite/ChangeLog: PR fortran/104349 * gfortran.dg/der_charlen_1.f90: Adjust dg-patterns. * gfortran.dg/pr104349.f90: New test. Diff: --- gcc/fortran/expr.cc | 2 -- gcc/testsuite/gfortran.dg/der_charlen_1.f90 | 2 ++ gcc/testsuite/gfortran.dg/pr104349.f90 | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index 7fb33f81788..02028f993fd 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -3504,8 +3504,6 @@ check_restricted (gfc_expr *e) || sym->attr.implied_index || sym->attr.flavor == FL_PARAMETER || is_parent_of_current_ns (sym->ns) - || (sym->ns->proc_name != NULL - && sym->ns->proc_name->attr.flavor == FL_MODULE) || (gfc_is_formal_arg () && (sym->ns == gfc_current_ns))) { t = true; diff --git a/gcc/testsuite/gfortran.dg/der_charlen_1.f90 b/gcc/testsuite/gfortran.dg/der_charlen_1.f90 index 9f394c73f25..1246522d516 100644 --- a/gcc/testsuite/gfortran.dg/der_charlen_1.f90 +++ b/gcc/testsuite/gfortran.dg/der_charlen_1.f90 @@ -22,3 +22,5 @@ CONTAINS type(T), intent(in) :: X end subroutine end module another_core + +! { dg-prune-output "cannot appear in the expression" } diff --git a/gcc/testsuite/gfortran.dg/pr104349.f90 b/gcc/testsuite/gfortran.dg/pr104349.f90 new file mode 100644 index 00000000000..2bea4a37214 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr104349.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/104349 - reject module variable as character length in PARAMETER +! Contributed by G.Steinmetz + +module m + character(n), parameter :: a(1) = 'b' ! { dg-error "cannot appear" } + character(n), parameter :: c = 'b' ! { dg-error "cannot appear" } +end
reply other threads:[~2023-04-04 16:50 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230404165021.0ABCB3858C54@sourceware.org \ --to=anlauf@gcc.gnu.org \ --cc=gcc-cvs@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).