diff mbox series

PR fortran/91943 -- More BOZ fallout

Message ID 20190930222308.GA2502@troutmask.apl.washington.edu
State New
Headers show
Series PR fortran/91943 -- More BOZ fallout | expand

Commit Message

Steve Kargl Sept. 30, 2019, 10:23 p.m. UTC
A BOZ cannot be an actual argument in a subroutine or function
reference except those intrinsic function listed in the Fortran
standard.  The attach patch checks for invalid BOZ.  Built and
tested on x86_64-*-freebsd.  OK to commit?

2019-09-30  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/91943
	* match.c (gfc_match_call): BOZ cannot be an actual argument in
	a subroutine reference.
	* resolve.c (resolve_function): BOZ cannot be an actual argument in
	a function reference.
 
2019-09-30  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/91943
	gfortran.dg/pr91943.f90

Comments

Janne Blomqvist Oct. 11, 2019, 2:55 p.m. UTC | #1
On Tue, Oct 1, 2019 at 1:23 AM Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
>
> A BOZ cannot be an actual argument in a subroutine or function
> reference except those intrinsic function listed in the Fortran
> standard.  The attach patch checks for invalid BOZ.  Built and
> tested on x86_64-*-freebsd.  OK to commit?
>
> 2019-09-30  Steven G. Kargl  <kargl@gcc.gnu.org>
>
>         PR fortran/91943
>         * match.c (gfc_match_call): BOZ cannot be an actual argument in
>         a subroutine reference.
>         * resolve.c (resolve_function): BOZ cannot be an actual argument in
>         a function reference.
>
> 2019-09-30  Steven G. Kargl  <kargl@gcc.gnu.org>
>
>         PR fortran/91943
>         gfortran.dg/pr91943.f90
>
> --
> Steve

Ok, though I believe your other BOZ patch that I just reviewed applies
on top of this one?
Steve Kargl Oct. 11, 2019, 3:34 p.m. UTC | #2
On Fri, Oct 11, 2019 at 05:55:45PM +0300, Janne Blomqvist wrote:
> On Tue, Oct 1, 2019 at 1:23 AM Steve Kargl
> <sgk@troutmask.apl.washington.edu> wrote:
> >
> > A BOZ cannot be an actual argument in a subroutine or function
> > reference except those intrinsic function listed in the Fortran
> > standard.  The attach patch checks for invalid BOZ.  Built and
> > tested on x86_64-*-freebsd.  OK to commit?
> >
> > 2019-09-30  Steven G. Kargl  <kargl@gcc.gnu.org>
> >
> >         PR fortran/91943
> >         * match.c (gfc_match_call): BOZ cannot be an actual argument in
> >         a subroutine reference.
> >         * resolve.c (resolve_function): BOZ cannot be an actual argument in
> >         a function reference.
> >
> > 2019-09-30  Steven G. Kargl  <kargl@gcc.gnu.org>
> >
> >         PR fortran/91943
> >         gfortran.dg/pr91943.f90
> >
> > --
> > Steve
> 
> Ok, though I believe your other BOZ patch that I just reviewed applies
> on top of this one?
> 

Yes.  This patch was applied in

r276471 | kargl | 2019-10-02 10:01:30 -0700 (Wed, 02 Oct 2019) | 13 lines

I had a growing stack of patches interfering/interacting with
each other.  As I completely changed how BOZ are handled, I
figure that this one could be committed without a review.
diff mbox series

Patch

Index: gcc/fortran/match.c
===================================================================
--- gcc/fortran/match.c	(revision 276271)
+++ gcc/fortran/match.c	(working copy)
@@ -4984,6 +4984,16 @@  gfc_match_call (void)
 	goto syntax;
     }
 
+  /* Walk the argument list looking for invalid BOZ.  */
+  for (a = arglist; a; a = a->next)
+    if (a->expr && a->expr->ts.type == BT_BOZ)
+      {
+	gfc_error ("A BOZ literal constant at %L cannot appear as an actual "
+		   "argument in a subroutine reference", &a->expr->where);
+	goto cleanup;
+      }
+
+
   /* If any alternate return labels were found, construct a SELECT
      statement that will jump to the right place.  */
 
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 276271)
+++ gcc/fortran/resolve.c	(working copy)
@@ -3242,6 +3242,21 @@  resolve_function (gfc_expr *expr)
   if (expr->expr_type != EXPR_FUNCTION)
     return t;
 
+  /* Walk the argument list looking for invalid BOZ.  */
+  if (expr->value.function.esym)
+    {
+      gfc_actual_arglist *a;
+
+      for (a = expr->value.function.actual; a; a = a->next)
+	if (a->expr && a->expr->ts.type == BT_BOZ)
+	  {
+	    gfc_error ("A BOZ literal constant at %L cannot appear as an "
+			"actual argument in a function reference",
+			&a->expr->where);
+	    return false;
+	  }
+    }
+
   temp = need_full_assumed_size;
   need_full_assumed_size = 0;
 
Index: gcc/testsuite/gfortran.dg/pr91943.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr91943.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr91943.f90	(working copy)
@@ -0,0 +1,7 @@ 
+! { dg-do compile }
+! PR fortran/91943
+! Code contributed by Gerhard Steinmetz
+program p
+   print *, f(b'1001')  ! { dg-error "cannot appear as an actual argument" }
+   call sub(b'1001')    ! { dg-error "cannot appear as an actual argument" }
+end