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] Fix PR 26039, lack of conformance checking in some intrinsics


Thomas,


+ if (m != NULL && m->rank != 0 && m->rank != a->rank) + { + gfc_error ("'%s' argument of '%s' intrinsic at %L must be conformable " + "with '%s' argument", gfc_current_intrinsic_arg[0], + gfc_current_intrinsic, &a->where, + gfc_current_intrinsic_arg[2]); + return FAILURE; + + } return SUCCESS; }




You are not testing for conformance - just equal ranks. Why don't you use gfc_check_conformance (const char*, gfc_expr *, gfc_expr*), which will check the shapes as well? The standard does actually specify conformability.

! { dg-do compile }
! PR 26039: Tests for different ranks for (min|max)loc, (min|max)val, product
! and sum were missing.
program main
integer, dimension(2) :: a
logical, dimension(2,1) :: lo
a = (/ 1, 2 /)
lo = .true.
print *,minloc(a,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,maxloc(a,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,minval(a,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,maxval(a,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,sum(a,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,product(a,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,minloc(a,1,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,maxloc(a,1,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,minval(a,1,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,maxval(a,1,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,sum(a,1,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
print *,product(a,1,mask=lo) ! { dg-error "must be conformable with 'mask' argument" }
end program main


Ditto.

Cheers

Paul


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