From b95605fb0c2052fcd1c2239acaa58748c9efc687 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Mon, 21 Nov 2005 16:05:58 +0000 Subject: [PATCH] re PR fortran/24223 (Gfortran crashes in two places) 2005-11-21 Paul Thomas 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 + + 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 * invoke.texi: Remove superfluous @item. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 0f175856a928..cb9c65bee7b0 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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); + } } diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 04f037b53f67..37e9db8d0b6f 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 045cf0a6e1a0..5dd8d06c44ca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2005-11-21 Paul Thomas * 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 index 000000000000..c053216c36b3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90 @@ -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 index 000000000000..622e1fc0e4ff --- /dev/null +++ b/gcc/testsuite/gfortran.dg/substring_equivalence.f90 @@ -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 -- 2.47.2