Paul Thomas - [Patch, fortran] PR30319 (original) (raw)
This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
[Patch, fortran] PR30319 - internal error in gfc_resolve_expr() for character parameter
- From: Paul Thomas
- To: gcc-patches , Fortran List
- Date: Sat, 10 Feb 2007 22:11:20 +0100
- Subject: [Patch, fortran] PR30319 - internal error in gfc_resolve_expr() for character parameter
:ADDPATCH fortran:This problem arises because the gfc_charlen of an initializer array constructor is shared with any parameters there might be in the constructor. Thus freeing the gfc_charlen to update to the length of the symbol being initialized is not a good idea.The fix is accomplished by building a new gfc_charlen, chained into the namespace so that it is cleaned up, and adding the symbol length to that. The testscase is that of the reporter.Bootstrapped and regtested on Cygwin_NT/amd64OK for trunk and after a delay of 1 week for 4.2?Paul
2007-02-10 Paul Thomas pault@gcc.gnu.org
PR fortran/30319
* decl.c (add_init_expr_to_sym): Make new charlen for an array
constructor initializer.
2007-02-10 Paul Thomas pault@gcc.gnu.org
PR fortran/30319
* gfortran.dg/char_array_constructor_2.f90
Index: gcc/fortran/decl.c
*** gcc/fortran/decl.c (revision 121540) --- gcc/fortran/decl.c (working copy) *************** add_init_expr_to_sym (const char name, *** 939,946 **** gfc_set_constant_character_len (len, init, false); else if (init->expr_type == EXPR_ARRAY) { ! gfc_free_expr (init->ts.cl->length); init->ts.cl->length = gfc_copy_expr (sym->ts.cl->length); for (p = init->value.constructor; p; p = p->next) gfc_set_constant_character_len (len, p->expr, false); } --- 939,951 ---- gfc_set_constant_character_len (len, init, false); else if (init->expr_type == EXPR_ARRAY) { ! / Build a new charlen so as not to delete one that ! is shared with a parameter, already declared. */ ! init->ts.cl = gfc_get_charlen (); ! init->ts.cl->next = gfc_current_ns->cl_list; ! gfc_current_ns->cl_list = sym->ts.cl; init->ts.cl->length = gfc_copy_expr (sym->ts.cl->length); + for (p = init->value.constructor; p; p = p->next) gfc_set_constant_character_len (len, p->expr, false); } Index: gcc/testsuite/gfortran.dg/char_array_constructor_2.f90
*** gcc/testsuite/gfortran.dg/char_array_constructor_2.f90 (revision 0) --- gcc/testsuite/gfortran.dg/char_array_constructor_2.f90 (revision 0)
*** 0 **** --- 1,14 ----
- ! { dg-do compile }
- ! Tests the fix for PR30319, in which the use of the parameter 'aa' in
- ! the array constructor that initialises bb would cause an internal
- ! error in resolution.
- !
- ! Contributed by Vivek Rao vivekrao4@yahoo.com
- !
- module foomod
- character (len=1), parameter :: aa = "z", bb(1) = (/aa/)
- end module foomod
- use foomod
- print *, aa, bb
- end
- ! { dg-final { cleanup-modules "foomod" } }
- Follow-Ups:
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |