2014-12-22 Janus Weil <janus@gcc.gnu.org>
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Dec 2014 18:15:08 +0000 (18:15 +0000)
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Dec 2014 18:15:08 +0000 (18:15 +0000)
PR fortran/63363
* check.c (gfc_check_kind): Reject polymorphic and non-data arguments.

2014-12-22  Janus Weil  <janus@gcc.gnu.org>

PR fortran/63363
* gfortran.dg/kind_1.f90: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219027 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/check.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/kind_1.f90 [new file with mode: 0644]

index de2d2a9..3b8ebdf 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-22  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/63363
+       * check.c (gfc_check_kind): Reject polymorphic and non-data arguments.
+
 2014-12-19  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/64209
index 95c5223..d2f35ec 100644 (file)
@@ -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;
 }
index 6009938..e756a17 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-22  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/63363
+       * gfortran.dg/kind_1.f90: New.
+
 2014-12-22  Oleg Endo  <olegendo@gcc.gnu.org>
 
        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 (file)
index 0000000..3230bfa
--- /dev/null
@@ -0,0 +1,24 @@
+! { dg-do compile }
+!
+! PR 63363: No diagnostic for passing function as actual argument to KIND
+!
+! Contributed by Ian Harvey <ian_harvey@bigpond.com>
+
+  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