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


i think you're right in that we do have to do more than just change the type. the type does need to change, to promote character scalar args to ints just as the C frontend does. however, since the fortran frontend will expect them as strings of length one, it seems they'll have to be converted to that upon entering a bind(c) routine.

thoughts?
Chris

On Mon, 30 Jul 2007, Steve Ellcey wrote:

thanks for trying it out.  i'm quite at a loss now as to why it's failing;
i thought that fixing the array_type still being seen in
gfc_conv_function_call would do it.  now i'm not even sure where to start
looking...  the only thing i could think to do now is to run cc1 through
gdb and figure out what the C frontend is doing with characters that isn't
happening on the fortran side.  it would be good to see the debug_tree
output for the tree created by cc1, but that would be a bit more work for
you.  i'll see if i can figure out where to put the call to debug_tree and
maybe pass it on to you.

thanks again for all of the help.
Chris

I wonder if we have to do more than change the type. If I understand the code correctly we have converted the type of the formal parameter in the call from an array of char to just a char. But the actual argument to the call (the variable or constant being passed) is still an array of char. Do we need code to change the actual argument so we wind up passing "array[1]" instead of "array", i.e. to pass in just the first element of the array instead of the entire array.

In C, if I have

	char s[10];
	call foo(s);

That is different then

	char s[10];
	call foo(s[0]);

Regardless of what prototype foo has and what type we claim the argument
to foo is.

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]