From: Janus Weil Date: Mon, 22 Dec 2014 18:15:08 +0000 (+0100) Subject: re PR fortran/63363 (No diagnostic for passing function as actual argument to KIND) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a6f14996acf4acf2788be390d84624959f6134d;p=gcc.git re PR fortran/63363 (No diagnostic for passing function as actual argument to KIND) 2014-12-22 Janus Weil PR fortran/63363 * check.c (gfc_check_kind): Reject polymorphic and non-data arguments. 2014-12-22 Janus Weil PR fortran/63363 * gfortran.dg/kind_1.f90: New. From-SVN: r219027 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index de2d2a91e26..3b8ebdfeff9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2014-12-22 Janus Weil + + PR fortran/63363 + * check.c (gfc_check_kind): Reject polymorphic and non-data arguments. + 2014-12-19 Janus Weil PR fortran/64209 diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 95c5223de65..d2f35ece5ae 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -2531,13 +2531,20 @@ gfc_check_kill_sub (gfc_expr *pid, gfc_expr *sig, gfc_expr *status) bool gfc_check_kind (gfc_expr *x) { - if (x->ts.type == BT_DERIVED) + if (x->ts.type == BT_DERIVED || x->ts.type == BT_CLASS) { - gfc_error ("%qs argument of %qs intrinsic at %L must be a " - "non-derived type", gfc_current_intrinsic_arg[0]->name, + gfc_error ("%qs argument of %qs intrinsic at %L must be of " + "intrinsic type", gfc_current_intrinsic_arg[0]->name, gfc_current_intrinsic, &x->where); return false; } + if (x->ts.type == BT_PROCEDURE) + { + gfc_error ("%qs argument of %qs intrinsic at %L must be a data entity", + gfc_current_intrinsic_arg[0]->name, gfc_current_intrinsic, + &x->where); + return false; + } return true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 600993881b2..e756a1738f0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-22 Janus Weil + + PR fortran/63363 + * gfortran.dg/kind_1.f90: New. + 2014-12-22 Oleg Endo PR target/52933 diff --git a/gcc/testsuite/gfortran.dg/kind_1.f90 b/gcc/testsuite/gfortran.dg/kind_1.f90 new file mode 100644 index 00000000000..3230bfa5f64 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/kind_1.f90 @@ -0,0 +1,24 @@ +! { dg-do compile } +! +! PR 63363: No diagnostic for passing function as actual argument to KIND +! +! Contributed by Ian Harvey + + type :: t + end type + type(t) :: d + class(*), allocatable :: c + + print *, KIND(d) ! { dg-error "must be of intrinsic type" } + print *, KIND(c) ! { dg-error "must be of intrinsic type" } + + print *, KIND(f) ! { dg-error "must be a data entity" } + print *, KIND(f()) + print *, KIND(s) ! { dg-error "must be a data entity" } +contains + FUNCTION f() + INTEGER(SELECTED_INT_KIND(4)) :: f + END FUNCTION + subroutine s + end subroutine +END