public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Benson <abenson@carnegiescience.edu>
To: Tobias Burnus <tobias@codesourcery.com>
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:45:00 -0000	[thread overview]
Message-ID: <2668495.6d4l6sgZZe@andrew-precision-3520> (raw)
In-Reply-To: <feb8bb04-8449-093a-7f17-996c08b2b291@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]

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.
> > 
> > A patch to fix this is attached. The patch regression tests cleanly - ok
> > to
> > commit?
> 
> The patch is okay, but can you add a comment – similar to the other
> patch – which makes clear why one needs twice the normal
> 
> GFC_MAX_SYMBOL_LEN (+2)? You currently have:
> >     const char dot[2] = ".";
> > 
> > -  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 updated 
patch is attached.

-Andrew

-- 

* Andrew Benson: http://users.obs.carnegiescience.edu/abenson/contact.html

* Galacticus: https://github.com/galacticusorg/galacticus

[-- Attachment #2: ChangeLog --]
[-- Type: text/x-changelog, Size: 216 bytes --]

2020-01-28  Andrew Benson  <abensonca@gmail.com>

	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.

[-- Attachment #3: patch.diff --]
[-- Type: text/x-patch, Size: 1797 bytes --]

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__

  reply	other threads:[~2020-01-28 16:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1642803.1Q0mUWRIpW@andrew-precision-3520>
2018-09-04 16:43 ` [patch, fortan] PR87103 - [OOP] ICE in gfc_new_symbol() due to overlong symbol name Andrew Benson
2018-09-04 17:43   ` Bernhard Reutner-Fischer
     [not found]     ` <5aa0135b-1bdd-46de-e235-daed0a9a97e1@charter.net>
2018-09-05 10:35       ` Bernhard Reutner-Fischer
2018-09-05 14:24         ` Andrew Benson
2019-08-24 14:50         ` Andrew Benson
2019-08-28 19:58           ` Bernhard Reutner-Fischer
2019-08-28 20:08             ` Andrew Benson
2020-01-29 22:49             ` Andrew Benson
2020-01-30 16:50               ` Bernhard Reutner-Fischer
2020-01-30 20:39                 ` Andrew Benson
2020-01-27 21:49   ` [patch, fortran] PR93461 - Bogus "symbol is already defined" with long subroutine names in submodule Andrew Benson
2020-01-28  8:50     ` Tobias Burnus
2020-01-28 16:46       ` Andrew Benson
2020-01-28 18:05         ` Tobias Burnus
2020-01-28 18:58           ` Andrew Benson
2020-01-29  2:11           ` [patch, fortran, wwwdocs] " Andrew Benson
2020-01-29  9:53             ` Gerald Pfeifer
2020-01-29 11:12             ` Tobias Burnus
2020-01-29 17:45               ` Andrew Benson
2020-01-28  0:03   ` [patch, fortran] PR93473 - ICE on valid with long module + submodule names Andrew Benson
2020-01-28  8:57     ` Tobias Burnus
2020-01-28 16:45       ` Andrew Benson [this message]
2020-01-28 17:51         ` Tobias Burnus
2020-01-28 18:49           ` Andrew Benson

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=2668495.6d4l6sgZZe@andrew-precision-3520 \
    --to=abenson@carnegiescience.edu \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias@codesourcery.com \
    /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: link
Be 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).