Message ID | AANLkTimEkr96PqN04QwDpxQfoKrg-FnuSa9oO1-z1cPJ@mail.gmail.com |
---|---|
State | New |
Headers | show |
> But adding this patchlet: > > > Index: gcc/fortran/primary.c > =================================================================== > --- gcc/fortran/primary.c (revision 163310) > +++ gcc/fortran/primary.c (working copy) > @@ -2017,8 +2017,6 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *t > } > > target = attr.target; > - if (pointer || attr.proc_pointer) > - target = 1; > > if (ts != NULL && expr->ts.type == BT_UNKNOWN) > *ts = sym->ts; > @@ -2074,8 +2072,6 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *t > pointer = comp->attr.pointer; > allocatable = comp->attr.allocatable; > } > - if (pointer || attr.proc_pointer) > - target = 1; > > break; > > > gives me a couple of regressions: > > > FAIL: gfortran.fortran-torture/execute/ptr.f90 compilation, -O0 > FAIL: gfortran.dg/c_loc_tests_14.f90 -O (test for excess errors) > FAIL: gfortran.dg/c_loc_tests_5.f03 -O (test for excess errors) > FAIL: gfortran.dg/pointer_assign_4.f90 -O0 (test for excess errors) > FAIL: gfortran.dg/pr43984.f90 -O (test for excess errors) > FAIL: gfortran.dg/subref_array_pointer_1.f90 -O0 (test for excess errors) > > All of them, except the C_LOC ones, fail on pointer assignments. And I > think all of them are actually invalid. Here is an updated patch, which fixes the invalid test cases. It should be free of regressions. Ok so far? I will re-check for regressions and take care of implicit SAVE in PROGRAMS tomorrow. Cheers, Janus
Janus Weil wrote: > FAIL: gfortran.fortran-torture/execute/ptr.f90 compilation, -O0 > FAIL: gfortran.dg/c_loc_tests_14.f90 -O (test for excess errors) > FAIL: gfortran.dg/c_loc_tests_5.f03 -O (test for excess errors) > FAIL: gfortran.dg/pointer_assign_4.f90 -O0 (test for excess errors) > FAIL: gfortran.dg/pr43984.f90 -O (test for excess errors) > FAIL: gfortran.dg/subref_array_pointer_1.f90 -O0 (test for excess errors) > > All of them, except the C_LOC ones, fail on pointer assignments. And I > think all of them are actually invalid. At least NAG f95 accepts them all. +++ gcc/testsuite/gfortran.dg/pr43984.f90 (working copy) - real(kind=kind(1.0d0)), dimension(:), pointer :: Izz - Izz => Iz(:,z) That looks perfectly valid, cf. below. - integer(c_int), dimension(:), pointer :: int_ptr - my_c_ptr = c_loc(int_ptr(0)) Well, as written is is invalid - but change it to - integer(c_int), dimension(:), pointer :: int_ptr ALLOCATE(int_ptr(0:10)) - my_c_ptr = c_loc(int_ptr(0)) Then it is valid. Note: "int_ptr(0)" is not a pointer but "int_ptr(0)" is the first element of the array to which int_ptr points. That array is unnamed but has the TARGET attribute. If you want to have a named target, use: integer, target :: tg(0:10) - integer(c_int), dimension(:), pointer :: int_ptr int_ptr => tg - my_c_ptr = c_loc(int_ptr(0)) In this case int_ptr(0) is the first element of "tg" and "tg" has the TARGET attribute. Tobias
> That looks perfectly valid, cf. below. > > - integer(c_int), dimension(:), pointer :: int_ptr > - my_c_ptr = c_loc(int_ptr(0)) > > > Well, as written is is invalid - but change it to > > - integer(c_int), dimension(:), pointer :: int_ptr > ALLOCATE(int_ptr(0:10)) > - my_c_ptr = c_loc(int_ptr(0)) > > > Then it is valid. ... which means that a through check for validity is very hard to do at compile time, since it depends on the run-time value, right? > Note: "int_ptr(0)" is not a pointer but "int_ptr(0)" is > the first element of the array to which int_ptr points. That array is > unnamed but has the TARGET attribute. If you want to have a named target, > use: > > integer, target :: tg(0:10) > - integer(c_int), dimension(:), pointer :: int_ptr > int_ptr => tg > - my_c_ptr = c_loc(int_ptr(0)) > > In this case int_ptr(0) is the first element of "tg" and "tg" has the TARGET > attribute. Well, ok. I guess that is one way to look at it. However, if I apply the same logic to your earlier pointer-init example ... module m integer, target, save :: t1 integer, pointer :: p1 => t1 integer, pointer :: p3 => p1 end module m ... then I'd say this is valid, too. p1 itself is a pointer, but the thing that it points to is a target (namely t1). Therefore "p3 => p1" is valid, since the object on the RHS has the TARGET attribute. Can we agree on that? Cheers, Janus
Index: gcc/fortran/primary.c =================================================================== --- gcc/fortran/primary.c (revision 163310) +++ gcc/fortran/primary.c (working copy) @@ -2017,8 +2017,6 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *t } target = attr.target; - if (pointer || attr.proc_pointer) - target = 1; if (ts != NULL && expr->ts.type == BT_UNKNOWN) *ts = sym->ts; @@ -2074,8 +2072,6 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *t pointer = comp->attr.pointer; allocatable = comp->attr.allocatable; } - if (pointer || attr.proc_pointer) - target = 1; break;