Hi Karl, see below for comment:
On Wed, 27 Jul 2016 17:19:42 -0700 Steve Kargl <s...@troutmask.apl.washington.edu> wrote: > Patch is self-explanatory. OK? > > 2016-07-26 Steven G. Kargl <ka...@gcc.gnu.org> > > PR fortran/71859 > * check.c(numeric_check): Prevent ICE. Issue error for > invalid subroutine as an actual argument when numeric argument is > expected. > > 2016-07-26 Steven G. Kargl <ka...@gcc.gnu.org> > > PR fortran/71859 > * gfortran.dg/pr71859.f90: New test. > * gfortran.dg/intrinsic_numeric_arg.f: Update error message. > * gfortran.dg/coarray_collectives_1.f90: Ditto. > > Index: gcc/fortran/check.c > =================================================================== > --- gcc/fortran/check.c (revision 238665) > +++ gcc/fortran/check.c (working copy) > @@ -72,6 +72,11 @@ type_check (gfc_expr *e, int n, bt type) > static bool > numeric_check (gfc_expr *e, int n) > { > + /* Users sometime use a subroutine designator as an actual > argument to > + an intrinsic subprogram that expects an argument with a numeric > type. */ > + if (e->symtree && e->symtree->n.sym->attr.subroutine) > + goto bandaid; > + > if (gfc_numeric_ts (&e->ts)) > return true; > > @@ -86,7 +91,9 @@ numeric_check (gfc_expr *e, int n) > return true; > } > > - gfc_error ("%qs argument of %qs intrinsic at %L must be a numeric > type", > +bandaid: Why bandaid? I would prefer error as label here, like it is done in several places in the code. Being a non-English-native I had to look up band-aid first to figure what it means. So that id is not intuitive to me. Besides that is the patch ok with me. Thanks. - Andre > + > + gfc_error ("%qs argument of %qs intrinsic at %L must have a > numeric type", gfc_current_intrinsic_arg[n]->name, > gfc_current_intrinsic, &e->where); > > Index: gcc/testsuite/gfortran.dg/pr71859.f90 > =================================================================== > --- gcc/testsuite/gfortran.dg/pr71859.f90 (nonexistent) > +++ gcc/testsuite/gfortran.dg/pr71859.f90 (working copy) > @@ -0,0 +1,8 @@ > +! { dg-do compile } > +program p > + call s(1) > + x = abs(s) ! { dg-error "must have a numeric type" } > +end > +subroutine s(n) > + print *, n > +end > Index: gcc/testsuite/gfortran.dg/intrinsic_numeric_arg.f > =================================================================== > --- gcc/testsuite/gfortran.dg/intrinsic_numeric_arg.f > (revision 238665) +++ > gcc/testsuite/gfortran.dg/intrinsic_numeric_arg.f (working > copy) @@ -4,6 +4,6 @@ LOGICAL Z > CHARACTER A > REAL R > - R = ABS(Z) ! { dg-error " must be a numeric type" } > - R = ABS(A) ! { dg-error " must be a numeric type" } > + R = ABS(Z) ! { dg-error " must have a numeric type" } > + R = ABS(A) ! { dg-error " must have a numeric type" } > END > Index: gcc/testsuite/gfortran.dg/coarray_collectives_1.f90 > =================================================================== > --- gcc/testsuite/gfortran.dg/coarray_collectives_1.f90 > (revision 238665) +++ > gcc/testsuite/gfortran.dg/coarray_collectives_1.f90 (working > copy) @@ -14,7 +14,7 @@ program test integer(8) :: i8 > character(len=19, kind=4) :: msg4 > > - call co_sum("abc") ! { dg-error "must be a numeric type" } > + call co_sum("abc") ! { dg-error "must have a numeric type" } > call co_max(cmplx(1.0,0.0)) ! { dg-error "shall be of type > integer, real or character" } call co_min(cmplx(0.0,1.0)) ! > { dg-error "shall be of type integer, real or character" } > > -- Andre Vehreschild * Email: vehre ad gmx dot de