From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41969 invoked by alias); 28 Jan 2020 16:41:33 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 41953 invoked by uid 89); 28 Jan 2020 16:41:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=H*MI:sk:feb8bb0, H*i:sk:feb8bb0, H*f:sk:feb8bb0 X-HELO: mail-pj1-f66.google.com Received: from mail-pj1-f66.google.com (HELO mail-pj1-f66.google.com) (209.85.216.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Jan 2020 16:41:31 +0000 Received: by mail-pj1-f66.google.com with SMTP id e9so1261863pjr.4; Tue, 28 Jan 2020 08:41:31 -0800 (PST) Return-Path: Received: from andrew-precision-3520.localnet (66-215-238-7.dhcp.rvsd.ca.charter.com. [66.215.238.7]) by smtp.gmail.com with ESMTPSA id a17sm3420561pjv.6.2020.01.28.08.41.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2020 08:41:29 -0800 (PST) From: Andrew Benson To: Tobias Burnus Cc: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [patch, fortran] PR93473 - ICE on valid with long module + submodule names Date: Tue, 28 Jan 2020 16:41:00 -0000 Message-ID: <2668495.6d4l6sgZZe@andrew-precision-3520> User-Agent: KMail/5.2.3 (Linux/4.4.0-170-generic; KDE/5.36.0; x86_64; ; ) In-Reply-To: References: <1642803.1Q0mUWRIpW@andrew-precision-3520> <2379883.S0vcn17Cz5@andrew-precision-3520> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart12545195.KYoYMYozVz" Content-Transfer-Encoding: 7Bit X-IsSubscribed: yes X-SW-Source: 2020-01/txt/msg00138.txt.bz2 This is a multi-part message in MIME format. --nextPart12545195.KYoYMYozVz Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Content-length: 1231 On Tuesday, January 28, 2020 9:27:58 AM PST Tobias Burnus wrote: > On 1/28/20 12:41 AM, Andrew Benson wrote: > > The problem occurs in set_syms_host_assoc() where the "parent1" and > > "parent2" variables have a maximum length of GFC_MAX_SYMBOL_LEN+1. This > > is insufficient when the parent names are a module+submodule name > > concatenated with a ".". The patch above fixes this by increasing their > > length to 2*GFC_MAX_SYMBOL_LEN+2. > >=20 > > A patch to fix this is attached. The patch regression tests cleanly - ok > > to > > commit? >=20 > The patch is okay, but can you add a comment =E2=80=93 similar to the oth= er > patch =E2=80=93 which makes clear why one needs twice the normal >=20 > GFC_MAX_SYMBOL_LEN (+2)? You currently have: > > const char dot[2] =3D "."; > >=20 > > - char parent1[GFC_MAX_SYMBOL_LEN + 1]; > > - char parent2[GFC_MAX_SYMBOL_LEN + 1]; > > + char parent1[2 * GFC_MAX_SYMBOL_LEN + 2]; > > + char parent2[2 * GFC_MAX_SYMBOL_LEN + 2]; Yes - I've added a comment here explaining the naming convention. An update= d=20 patch is attached. -Andrew --=20 * Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html * Galacticus: https://github.com/galacticusorg/galacticus --nextPart12545195.KYoYMYozVz Content-Disposition: attachment; filename="ChangeLog" Content-Transfer-Encoding: 7Bit Content-Type: text/x-changelog; charset="UTF-8"; name="ChangeLog" Content-length: 216 2020-01-28 Andrew Benson PR fortran/93473 * parse.c: Increase length of char variables to allow them to hold a concatenated module + submodule name. * gfortran.dg/pr93473.f90: New test. --nextPart12545195.KYoYMYozVz Content-Disposition: attachment; filename="patch.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="patch.diff" Content-length: 1797 diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 4bff0c8..f71a95d 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -6045,8 +6045,9 @@ set_syms_host_assoc (gfc_symbol *sym) { gfc_component *c; const char dot[2] = "."; - char parent1[GFC_MAX_SYMBOL_LEN + 1]; - char parent2[GFC_MAX_SYMBOL_LEN + 1]; + /* Symbols take the form module.submodule_ or module.name_. */ + char parent1[2 * GFC_MAX_SYMBOL_LEN + 2]; + char parent2[2 * GFC_MAX_SYMBOL_LEN + 2]; if (sym == NULL) return; diff --git a/gcc/testsuite/gfortran.dg/pr93473.f90 b/gcc/testsuite/gfortran.dg/pr93473.f90 new file mode 100644 index 0000000..dda8525 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93473.f90 @@ -0,0 +1,28 @@ +! { dg-do compile } +! { dg-options "-ffree-line-length-none" } +! PR fortran/93473 +module aModestlyLongModuleName + + type :: aTypeWithASignificantlyLongNameButStillAllowedOK + end type aTypeWithASignificantlyLongNameButStillAllowedOK + + interface + module function aFunctionWithALongButStillAllowedName(parameters) result(self) + type(aTypeWithASignificantlyLongNameButStillAllowedOK) :: self + end function aFunctionWithALongButStillAllowedName + end interface + +end module aModestlyLongModuleName + +submodule (aModestlyLongModuleName) aTypeWithASignificantlyLongNameButStillAllowedOK_ + +contains + + module procedure aFunctionWithALongButStillAllowedName + class(*), pointer :: genericObject + end procedure aFunctionWithALongButStillAllowedName + +end submodule aTypeWithASignificantlyLongNameButStillAllowedOK_ + +submodule (aModestlyLongModuleName:aTypeWithASignificantlyLongNameButStillAllowedOK_) aSubmoduleWithASignificantlyLongButStillAllowedName__ +end submodule aSubmoduleWithASignificantlyLongButStillAllowedName__ --nextPart12545195.KYoYMYozVz--