This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

Re: [patch,gfortran] PR 24503: Character functions of non-constant length


On Thu, Oct 27, 2005 at 03:50:18PM +0300, Erik Edelmann wrote:
> On Wed, Oct 26, 2005 at 01:58:44PM +0300, Erik Edelmann wrote:
> > On Tue, Oct 25, 2005 at 10:44:26AM -0400, Jakub Jelinek wrote:
> > > Please test the same when using ENTRY without RESULT.
> > 
> > Ok. I tried, and it didn't work:
> 
>         <...>
> 
> > Am I doing something wrong, or are ENTRY in functions (of any
> > type) broken in gfortran? (Since this is the first time in my
> > life I use ENTRY, it's not unlikely that I'm doing something
> > wrong.  Both testcases compile and run without trouble in Absoft
> > and Intel compilers, but that does, after all, not prove
> > anything)
> 
> It seems that it's only in modules that ENTRY statements are
> completely broken (PR 24558).  For external functions, ENTRY:s
> work for other cases, but not (yet) for functions of type
> CHARACTER(len=<non-constant>).  If it passes testing, I'll post
> and extended version of my patch to address this problem tonight.

Ok, here it comes.  It's the same as my previous patch, with the
following addition: in trans-expr.c (gfc_conv_variable), if the
charcter length hasn't been set of an ENTRY, the length is taken
from the master function instead.  This is needed because the
character lengths of entries are set from the master function in
trans.decl.c (gfc_generate_function_code) before
gfc_get_fake_result_decl() (where character lengths for fake
result variables of non constant length is set), is called.

I have to admit that I'm not perfectly happy with the approach
taken by this patch.  I would prefer to have the character lentgh
set once and for all at one place, instead of having all these
'if (sym->ts.type == BT_CHARACTER && !sym->ts.cl->backend_decl)'
special cases scattered all over the code.  To achieve that,
however, doesn't seem to be easy (I tried a few different
approaches, but non would work).

Bubblestrapped and tested on Linux/x86.  OK to commit?



        Erik


(The PR number in the ChangeLog entries below has changed,
because PR 24503 was declared a duplicate of PR 18883)


2005-10-28  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR fortran/18883
        * trans-decl.c (gfc_finish_var_decl): Add decl to the
        current function, rather than the parent.  Make
        assertion accept fake result variables.
        * trans-expr.c (gfc_conv_variable): If the character
        length of an ENTRY isn't set, get the length from
        the master function instead.



2005-10-28  Erik Edelmann  <eedelman@gcc.gnu.org>

        PR fortran/18883
        * gfortran.dg/char_result_9.f90: New.
        * gfortran.dg/char_result_10.f90: New.

Attachment: 24503-2.diff
Description: Text document

Attachment: char_result_9.f90
Description: Text document

Attachment: char_result_10.f90
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]