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: [Bug fortran/32732] [Bind C] Character scalars are passed as arrays


> first, a comment on the code snippet you gave: the reason you have to add 
> -fno-underscoring is because your main program forgets to say 'use 
> c_char_tests', so sub0 gets implicitly declared.

Ah yes, I added that and I can compile without the -fno-underscoring.

> second, i think i've tracked down what was causing the problem with the 
> code snippet.  the call to sub0 gets converted (gfc_conv_function_call) 
> before the generate_local_decls runs for param_test.  this means that the 
> symbols for the dummy args in the call still say they're an array_type, so 
> the actuals given by sub0() are converted to array_type.  i think this 
> means that the fixup done for by-value character dummies in 
> generate_local_decl must also be done when mapping actuals to formals in 
> gfc_conv_function_call.  i've attached a patch that does this.  it's been 
> bootstrapped and regtested on x86 and x86_64 linux with no new failures, 
> but the real test is whether they'll work for you.  :-)

It doesn't look like it is working.  I put in your patch (after removing
the previous trans-decl.c patch) Then I rebuilt and tested my program
and it still failed.  Looking at the assembly language, there are still
shifts of the characters in sub0 before it calls param_test so it looks
like sub0 is still passing the arguments as arrays.

I am not sure why this is, I do hit the new code in trans-expr.c, before
calling gfc_conv_scalar_char_value I have:

 <parm_decl 7d6cc2d8 my_char
    type <array_type 7d76e230
        type <integer_type 7d6d8150 char public unsigned string-flag QI
            size <integer_cst 7d6c51b8 constant invariant 8>
            unit size <integer_cst 7d6c51e0 constant invariant 1>
            align 8 symtab 0 alias set -1 canonical type 7d6d8150 precision 8 min <integer_cst 7d6c5208 0> max <integer_cst 7d6c5230 255>
            pointer_to_this <pointer_type 7d6e0690>>
        string-flag QI size <integer_cst 7d6c51b8 8> unit size <integer_cst 7d6c51e0 1>
        align 8 symtab 0 alias set -1 canonical type 7d76e230
        domain <integer_type 7d76e1c0 type <integer_type 7d6d8310 int4>
            SI
            size <integer_cst 7d6c53e8 constant invariant 32>
            unit size <integer_cst 7d6c50f0 constant invariant 4>
            align 32 symtab 0 alias set -1 canonical type 7d76e1c0 precision 32 min <integer_cst 7d6c5898 1> max <integer_cst 7d6c5898 1>>>
    readonly QI file x.f90 line 5 size <integer_cst 7d6c51b8 8> unit size <integer_cst 7d6c51e0 1>
    align 8 context <function_decl 7d76dd20 param_test> initial <array_type 7d76e230> arg-type <array_type 7d76e230> chain <parm_decl 7d6cc3a8 my_char_2>>

And after calling gfc_conv_scalar_char_value I have:

 <parm_decl 7d6cc2d8 my_char
    type <integer_type 7d6d8150 char public unsigned string-flag QI
        size <integer_cst 7d6c51b8 constant invariant 8>
        unit size <integer_cst 7d6c51e0 constant invariant 1>
        align 8 symtab 0 alias set -1 canonical type 7d6d8150 precision 8 min <integer_cst 7d6c5208 0> max <integer_cst 7d6c5230 255>
        pointer_to_this <pointer_type 7d6e0690>>
    readonly QI file x.f90 line 5 size <integer_cst 7d6c51b8 8> unit size <integer_cst 7d6c51e0 1>
    align 8 context <function_decl 7d76dd20 param_test> initial <integer_type 7d6d8150 char> arg-type <integer_type 7d6d8150 char> chain <parm_decl 7d6cc3a8 my_char_2>>

But the arguments are still shifted before being passed from sub0 to
param_test.  I don't know why.

Steve Ellcey
sje@cup.hp.com


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