re PR fortran/24223 (Gfortran crashes in two places)
authorPaul Thomas <pault@gcc.gnu.org>
Mon, 21 Nov 2005 16:05:58 +0000 (16:05 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Mon, 21 Nov 2005 16:05:58 +0000 (16:05 +0000)
2005-11-21  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/24223
* resolve.c (resolve_contained_fntype) Error if an internal
function is assumed character length.

PR fortran/24705
* trans-decl.c (gfc_create_module_variable) Skip ICE in
when backend decl has been built and the symbol is marked
as being in an equivalence statement.

2005-11-21  Paul Thomas  <pault@gcc.gnu.org

PR fortran/24223
* gfortran.dg/substring_equivalence.f90: New test.

PR fortran/24705
* gfortran.dg/auto_internal_assumed.f90: New test.

From-SVN: r107310

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/auto_internal_assumed.f90 [new file with mode: 0755]
gcc/testsuite/gfortran.dg/substring_equivalence.f90 [new file with mode: 0755]

index 1d7f9cf75f40f281d596427189a13e11ad826251..355430d553aa5b0029c8aa92650b9e9e14dc1b62 100644 (file)
@@ -1,3 +1,14 @@
+2005-11-21  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/24223
+       * resolve.c (resolve_contained_fntype) Error if an internal
+       function is assumed character length.
+
+       PR fortran/24705
+       * trans-decl.c (gfc_create_module_variable) Skip ICE in
+       when backend decl has been built and the symbol is marked
+       as being in an equivalence statement.
+
 2005-11-20  Toon Moene  <toon@moene.indiv.nluug.nl>
 
        * invoke.texi: Remove superfluous @item.
index 0f175856a928268b465bfa2f65ee032fd13763bd..cb9c65bee7b076bfb1aa38bea4501601d2c2255e 100644 (file)
@@ -294,6 +294,19 @@ resolve_contained_fntype (gfc_symbol * sym, gfc_namespace * ns)
          sym->attr.untyped = 1;
        }
     }
+
+  /*Fortran 95 Draft Standard, page 51, Section 5.1.1.5, on the Character type,
+    lists the only ways a character length value of * can be used: dummy arguments
+    of proceedures, named constants, and function results in external functions.
+    Internal function results are not on that list; ergo, not permitted.  */
+
+  if (sym->ts.type == BT_CHARACTER)
+    {
+      gfc_charlen *cl = sym->ts.cl;
+      if (!cl || !cl->length)
+       gfc_error ("Character-valued internal function '%s' at %L must "
+                  "not be assumed length", sym->name, &sym->declared_at);
+    }
 }
 
 
index 04f037b53f67c5d4aed9be71392725b3f2bbba62..37e9db8d0b6fd136e02b47b12b9540f62cc66251 100644 (file)
@@ -2366,7 +2366,8 @@ gfc_create_module_variable (gfc_symbol * sym)
     return;
 
   /* Equivalenced variables arrive here after creation.  */
-  if (sym->backend_decl && sym->equiv_built)
+  if (sym->backend_decl
+       && (sym->equiv_built || sym->attr.in_equivalence))
       return;
 
   if (sym->backend_decl)
index 045cf0a6e1a0487abce066b5d3550f936ab487a2..5dd8d06c44ca5461eace295fb61b3d02aa9ab1e4 100644 (file)
@@ -1,3 +1,11 @@
+2005-11-21  Paul Thomas  <pault@gcc.gnu.org
+
+       PR fortran/24223
+       * gfortran.dg/substring_equivalence.f90: New test.
+
+       PR fortran/24705
+       * gfortran.dg/auto_internal_assumed.f90: New test.
+
 2005-11-21  Uros Bizjak  <uros@kss-loka.si>
 
        * gcc.dg/fold-div-2.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90 b/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90
new file mode 100755 (executable)
index 0000000..c053216
--- /dev/null
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! Test fix of PR24705 - ICE on assumed character length
+! internal function.
+!
+character (6) :: c
+  c = f1 ()        ! { dg-error "must not be assumed length" }
+  if (c .ne. 'abcdef') call abort
+contains
+  function f1 ()
+    character (*) :: f1
+    f1 = 'abcdef'
+  end function f1
+end
\ No newline at end of file
diff --git a/gcc/testsuite/gfortran.dg/substring_equivalence.f90 b/gcc/testsuite/gfortran.dg/substring_equivalence.f90
new file mode 100755 (executable)
index 0000000..622e1fc
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! Tests fix for PR24223 - ICE on equivalence staement.
+!
+module FLAGS
+  character(len=5) :: Encodings
+  character :: at, dev
+  equivalence ( encodings(1:1),at ), ( encodings(2:2),dev)
+end module FLAGS