diff mbox series

PR fortran/35031 -- Check F2018:C1246

Message ID 20190111011606.GA73766@troutmask.apl.washington.edu
State New
Headers show
Series PR fortran/35031 -- Check F2018:C1246 | expand

Commit Message

Steve Kargl Jan. 11, 2019, 1:16 a.m. UTC
An entry-name obtains the elemental attribute from its containing
procedure.  F2018:C1546 prohibits an procedure from having a BIND(C)
attribute.  BIND(C) can appear on the entry-stmt line, so gfortran
needs to check for a conflict.  The attached patch does this check.
Tested on x86_64-*-freebsd.  Ok to commit?

2019-01-10  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/35031
	* decl.c (gfc_match_entry): Check for F2018:C1546.  Fix nearby
	mis-indentation.
 
2019-01-10  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/35031
	* gfortran.dg/pr35031.f90: new test.

Comments

Paul Richard Thomas Jan. 11, 2019, 11:17 a.m. UTC | #1
Hi Steve,

Yes, that's good for trunk.

Thanks

Paul

On Fri, 11 Jan 2019 at 01:16, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
>
> An entry-name obtains the elemental attribute from its containing
> procedure.  F2018:C1546 prohibits an procedure from having a BIND(C)
> attribute.  BIND(C) can appear on the entry-stmt line, so gfortran
> needs to check for a conflict.  The attached patch does this check.
> Tested on x86_64-*-freebsd.  Ok to commit?
>
> 2019-01-10  Steven G. Kargl  <kargl@gcc.gnu.org>
>
>         PR fortran/35031
>         * decl.c (gfc_match_entry): Check for F2018:C1546.  Fix nearby
>         mis-indentation.
>
> 2019-01-10  Steven G. Kargl  <kargl@gcc.gnu.org>
>
>         PR fortran/35031
>         * gfortran.dg/pr35031.f90: new test.
>
> --
> Steve
diff mbox series

Patch

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 267825)
+++ gcc/fortran/decl.c	(working copy)
@@ -7431,9 +7431,11 @@  gfc_match_entry (void)
 	      gfc_error ("Missing required parentheses before BIND(C) at %C");
 	      return MATCH_ERROR;
 	    }
-	    if (!gfc_add_is_bind_c (&(entry->attr), entry->name,
-				    &(entry->declared_at), 1))
-	      return MATCH_ERROR;
+
+	  if (!gfc_add_is_bind_c (&(entry->attr), entry->name,
+				  &(entry->declared_at), 1))
+	    return MATCH_ERROR;
+	
 	}
 
       if (!gfc_current_ns->parent
@@ -7514,6 +7516,14 @@  gfc_match_entry (void)
   if (gfc_match_eos () != MATCH_YES)
     {
       gfc_syntax_error (ST_ENTRY);
+      return MATCH_ERROR;
+    }
+
+  /* F2018:C1546 An elemental procedure shall not have the BIND attribute.  */
+  if (proc->attr.elemental && entry->attr.is_bind_c)
+    {
+      gfc_error ("ENTRY statement at %L with BIND(C) prohibited in an "
+		 "elemental procedure", &entry->declared_at);
       return MATCH_ERROR;
     }
 
Index: gcc/testsuite/gfortran.dg/pr35031.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr35031.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr35031.f90	(working copy)
@@ -0,0 +1,10 @@ 
+! { dg-do compile }
+elemental subroutine sub2(x)
+   integer, intent(in) :: x
+   entry sub2_c(x) bind(c)    ! { dg-error "prohibited in an elemental" }
+end subroutine sub2
+
+elemental function func2(x)
+   integer, intent(in) :: x
+   entry func2_c(x) bind(c)   ! { dg-error "prohibited in an elemental" }
+end function func2