From 0a6f14996acf4acf2788be390d84624959f6134d Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Mon, 22 Dec 2014 19:15:08 +0100 Subject: [PATCH] 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 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/check.c | 13 ++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/kind_1.f90 | 24 ++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/kind_1.f90 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