Allow concatenated module+submodule names.
authorAndrew Benson <abenson@carnegiescience.edu>
Tue, 28 Jan 2020 17:58:40 +0000 (17:58 +0000)
committerAndrew Benson <abenson@carnegiescience.edu>
Tue, 28 Jan 2020 18:02:49 +0000 (18:02 +0000)
Increase length of char variables "parent1" and "parent2" in
set_syms_host_assoc() to allow them to hold concatenated module +
submodule names.

        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.

gcc/fortran/ChangeLog
gcc/fortran/parse.c
gcc/testsuite/gfortran.dg/pr93473.f90 [new file with mode: 0644]

index c7e2b31933769b36ec71bf1e618fb048d39f186d..3e8a24ce8cf2668cc92b1b93bf23942b940929a4 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2020-01-28  Julian Brown  <julian@codesourcery.com>
 
        PR fortran/93025
index 4bff0c885e2322f8b09419c65b5dac8fa36ba403..f71a95dd8719b5855f2421302d039e0aaf5fdc50 100644 (file)
@@ -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 (file)
index 0000000..dda8525
--- /dev/null
@@ -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__