------- Comment #5 from janus at gcc dot gnu dot org 2010-07-13 12:12 -------
(In reply to comment #3)
> For the program in comment 0, NAG prints:
> Error: aaa.f90, line 16: The argument to C_LOC must not be polymorphic
> though ifort and crayftn accept the code. Thus, at least with
> -std=f95/f2003/f2008 one should reject it.
Ah, good point. I totally forgot about the fact that a polymorphic variable is
by definition not interoperable.
Still comment #0 is a bug, since the error message is totally wrong.
> > > However, it regresses at least on c_loc_tests_5.f03 and
> > > c_loc_tests_14.f90.
> >
> > Actually I have the feeling that both of these test cases are invalid, and
> > the
> > patch is right to reject them.
>
> Well, NAG, ifort, pgi, and crayftn compile both programs; g95 compiles at
> least
> c_loc_tests_5.f03; thus, I am inclined to say that those two tests are valid.
I think Sun Studio 12 even rejects both of them.
Anyway, we should refer to the standard rather than other compilers to fix
this. F08 clearly states for the argument of C_LOC: "X shall have either the
POINTER or TARGET attribute".
c_loc_tests_5.f03 has:
integer(c_int), dimension(:), pointer :: int_ptr
my_c_ptr = c_loc(int_ptr(0))
Here int_ptr is a pointer to an array of integers, but int_ptr(0) is an element
of that array, so it doesn't have the POINTER attribute, does it?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44925