public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR fortran/85687 -- Check argument of RANK.
@ 2018-05-09 22:28 Steve Kargl
  0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2018-05-09 22:28 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 343 bytes --]

I plan to commit the attached patch on Saturday unless 
someone voices an objection.

2018-05-09  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/85687
	* check.c (gfc_check_rank): Check that the argument is a data object.

2018-05-09  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/85687
	* gfortran.dg/pr85687.f90: new test.

-- 
Steve

[-- Attachment #2: pr85687.diff --]
[-- Type: text/x-diff, Size: 1202 bytes --]

Index: gcc/fortran/check.c
===================================================================
--- gcc/fortran/check.c	(revision 260098)
+++ gcc/fortran/check.c	(working copy)
@@ -3886,8 +3886,11 @@ gfc_check_rank (gfc_expr *a)
 		  ? a->value.function.esym->result->attr.pointer
 		  : a->symtree->n.sym->result->attr.pointer;
 
-  if (a->expr_type == EXPR_OP || a->expr_type == EXPR_NULL
-      || a->expr_type == EXPR_COMPCALL|| a->expr_type == EXPR_PPC
+  if (a->expr_type == EXPR_OP
+      || a->expr_type == EXPR_NULL
+      || a->expr_type == EXPR_COMPCALL
+      || a->expr_type == EXPR_PPC
+      || a->ts.type == BT_PROCEDURE
       || !is_variable)
     {
       gfc_error ("The argument of the RANK intrinsic at %L must be a data "
Index: gcc/testsuite/gfortran.dg/pr85687.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr85687.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr85687.f90	(working copy)
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/85687
+! Code original contributed by Gerhard Steinmetz gscfq at t-oline dot de
+program p
+   type t
+   end type
+   print *, rank(t)  ! { dg-error "must be a data object" }
+end

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-05-09 22:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09 22:28 [PATCH] PR fortran/85687 -- Check argument of RANK Steve Kargl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).