This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR fortran/91564 -- Additonal checks on STATUS


The attached patch has been built and tested on x86_64-*-freebsd.
It adds additional checks for the status dummy argument, and
therby prevents an ICE.  OK to commit?

2019-08-27  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/91564
	* check.c (gfc_check_kill_sub): Additional checks on status dummy
	argument.

2019-08-27  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/91564
	* gfortran.dg/pr91564.f90: New test.
-- 
Steve
Index: gcc/fortran/check.c
===================================================================
--- gcc/fortran/check.c	(revision 274961)
+++ gcc/fortran/check.c	(working copy)
@@ -3301,6 +3301,22 @@ gfc_check_kill_sub (gfc_expr *pid, gfc_expr *sig, gfc_
 
       if (!scalar_check (status, 2))
 	return false;
+
+      if (status->expr_type != EXPR_VARIABLE)
+	{
+	  gfc_error ("STATUS at %L shall be an INTENT(OUT) variable",
+		     &status->where);
+	  return false;
+	}
+
+      if (status->expr_type == EXPR_VARIABLE
+	  && status->symtree && status->symtree->n.sym
+	  && status->symtree->n.sym->attr.intent == INTENT_IN)
+	{
+	  gfc_error ("%qs at %L shall be an INTENT(OUT) variable",
+		     status->symtree->name, &status->where);
+	  return false;
+	}
     }
 
   return true;
Index: gcc/testsuite/gfortran.dg/pr91564.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr91564.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr91564.f90	(working copy)
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! PR fortran/91564
+! Contributed by Gerhard Steinmetz.
+program p
+   integer i, j
+   call kill (1, 2, 3)        ! { dg-error "shall be an INTENT" }
+   i = 42
+   call bar(i, j)
+end
+
+subroutine bar(n, m)
+   integer, intent(in) :: n
+   integer, intent(inout) :: m
+   call kill (1, 3, n)        ! { dg-error "shall be an INTENT" }
+   call kill (1, 3, m)
+end subroutine bar

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]