This is the mail archive of the gcc-patches@gcc.gnu.org mailing 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]

Re: [Patch,Fortran] PR 40632 - Add CONTIGUOUS attribute (part 1)


Hi Mikael,

thanks for the fast review!

I agree that the error message is a bit cryptic, but do you (or anyone
else) have a better suggestion? The constraints are also rather lengthy
and convoluted:

C1239 (R1223) If an actual argument is a nonpointer array that has the
ASYNCHRONOUS or VOLATILE attribute but is not simply contiguous (6.5.4),
and the corresponding dummy argument has either the VOLATILE or
ASYNCHRONOUS attribute, that dummy argument shall be an assumed-shape
array that does not have the CONTIGUOUS attribute.

C1240 (R1223) If an actual argument is an array pointer that has the
ASYNCHRONOUS or VOLATILE attribute but does not have the CONTIGUOUS
attribute, and the corresponding dummy argument has either the VOLATILE
or ASYNCHRONOUS attribute, that dummy argument shall be an array pointer
or an assumed-shape array that does not have the CONTIGUOUS attribute.

Mikael Morin wrote:
>> +  /* F2008, C1239/C1240.  */
>> +  if (actual->expr_type == EXPR_VARIABLE
>> +      && (actual->symtree->n.sym->attr.asynchronous
>> +         || actual->symtree->n.sym->attr.volatile_)
>> +      &&  (formal->attr.asynchronous || formal->attr.volatile_)
>> +      && actual->rank && !gfc_is_simply_contiguous (actual, true)
>> +      && ((formal->as->typI have to checke != AS_ASSUMED_SHAPE &&
>> !formal->attr.pointer)
>> +      || formal->attr.contiguous))
>> +    {
>> +      if (where)
>> +    gfc_error ("Dummy argument '%s' has to be a pointer or
>> assumed-shape "
>> +           "array without CONTIGUOUS attribute as actual argument at "
>> +           "%L is not not simply contiguous and both are ASYNCHRONOUS "
>> +           "or VOLATILE", formal->name, &actual->where);
>> +      return 0;
>>      }
> The error message is a bit cryptic to me. 

It becomes a bit clearer if one replaces "both" by "actual and dummy
argument" - but that's even longer.

 * * *

> I think you are not rejecting the case array(:,1,:)

I have to check. I think you are right. Additionally, the following
program give the wrong result; I don't know whether it should be
accepted with copy-in/copy-out or whether it should be rejected at
compiler time, but instead of 1,3,5,7 it prints with the patch 1,2,3,4.
(The program might even be invalid, but then it can and should be
rejected at compile time. crayftn accepts it,)

Thus, back to the standard and the drawing board - I need to recheck
again what has to be done and think about what should be done. Somehow
the concept of being "contiguous" sounds so simple, but specifying it
(in the standard) and implementing it, is more difficult than expected -
especially, in the general case, it is impossible to tell at compile
time whether an object is contiguous or not - only whether it is simply
contiguous can be checked.

implicit none
integer :: a(8),i
a = [(i,i=1,8)]
call foo(a(::2))
contains
subroutine foo(x)
  integer, contiguous :: x(:)
  print *, x
  if (any (x != [1,3,5,7])) call abort()
end subroutine
end

Tobias


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