diff mbox series

PR fortran/85895 -- Check for valid errmsg entity

Message ID 20180523234525.GA42107@troutmask.apl.washington.edu
State New
Headers show
Series PR fortran/85895 -- Check for valid errmsg entity | expand

Commit Message

Steve Kargl May 23, 2018, 11:45 p.m. UTC
The attach patch fixes PR fortran/85895 and also addresses
a nearby issue by resolving the expressions associated with
the STAT= and ERRMSG= tags in SYNC statements.  OK to commit?

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

	PR fortran/85895
	* resolve.c (resolve_sync): Resolve expression before checking for
	an error.

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

	PR fortran/85895

	* gfortran.dg/coarray_3.f90: Fix invalid testcase.
	* gfortran.dg/pr85895.f90: New test.

Comments

Janus Weil May 24, 2018, 8:14 p.m. UTC | #1
2018-05-24 1:45 GMT+02:00 Steve Kargl <sgk@troutmask.apl.washington.edu>:
> The attach patch fixes PR fortran/85895 and also addresses
> a nearby issue by resolving the expressions associated with
> the STAT= and ERRMSG= tags in SYNC statements.  OK to commit?

Looks good to me. Thanks for the patch!

Cheers,
Janus



> 2018-05-23  Steven G. Kargl  <kargl@gcc.gnu.org>
>
>         PR fortran/85895
>         * resolve.c (resolve_sync): Resolve expression before checking for
>         an error.
>
> 2018-05-23  Steven G. Kargl  <kargl@gcc.gnu.org>
>
>         PR fortran/85895
>
>         * gfortran.dg/coarray_3.f90: Fix invalid testcase.
>         * gfortran.dg/pr85895.f90: New test.
>
> --
> Steve
diff mbox series

Patch

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 260623)
+++ gcc/fortran/resolve.c	(working copy)
@@ -9527,6 +9527,7 @@  resolve_sync (gfc_code *code)
     }
 
   /* Check STAT.  */
+  gfc_resolve_expr (code->expr2);
   if (code->expr2
       && (code->expr2->ts.type != BT_INTEGER || code->expr2->rank != 0
 	  || code->expr2->expr_type != EXPR_VARIABLE))
@@ -9534,6 +9535,7 @@  resolve_sync (gfc_code *code)
 	       &code->expr2->where);
 
   /* Check ERRMSG.  */
+  gfc_resolve_expr (code->expr3);
   if (code->expr3
       && (code->expr3->ts.type != BT_CHARACTER || code->expr3->rank != 0
 	  || code->expr3->expr_type != EXPR_VARIABLE))
Index: gcc/testsuite/gfortran.dg/coarray_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/coarray_3.f90	(revision 260623)
+++ gcc/testsuite/gfortran.dg/coarray_3.f90	(working copy)
@@ -13,7 +13,7 @@  end critical fkl ! { dg-error "Expecting END PROGRAM" 
 
 sync all (stat=1) ! { dg-error "Syntax error in SYNC ALL" }
 sync all ( stat = n,stat=k) ! { dg-error "Redundant STAT" }
-sync memory (errmsg=str)
+sync memory (errmsg=str) ! { dg-error "must be a scalar CHARACTER variable" }
 sync memory (errmsg=n) ! { dg-error "must be a scalar CHARACTER variable" }
 sync images (*, stat=1.0) ! { dg-error "Syntax error in SYNC IMAGES" }
 sync images (-1) ! { dg-error "must between 1 and num_images" }
Index: gcc/testsuite/gfortran.dg/pr85895.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr85895.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr85895.f90	(working copy)
@@ -0,0 +1,17 @@ 
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+! PR fortran/85895
+subroutine p
+   character(80) :: c(2)
+   sync memory (errmsg=c)        ! { dg-error "scalar CHARACTER variable" }
+end subroutine p
+
+subroutine q
+   character(80) :: c(2)
+   sync memory (errmsg=c(1:2))   ! { dg-error "scalar CHARACTER variable" }
+end subroutine q
+
+subroutine r
+   character(80) :: c(2)
+   sync memory (errmsg=c(1))
+end subroutine r