re PR fortran/68319 (ICE on using interface with included entry)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 13 Nov 2015 21:11:42 +0000 (21:11 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 13 Nov 2015 21:11:42 +0000 (21:11 +0000)
2015-11-13  Steven G. Kargl  <kargl@gccc.gnu.org>

PR fortran/68319
* decl.c (gfc_match_data, gfc_match_entry): Enforce F2008:C1206.
* io.c (gfc_match_format): Ditto.
* match.c (gfc_match_st_function): Ditto.

2015-11-13  Steven G. Kargl  <kargl@gccc.gnu.org>

PR fortran/68319
* gfortran.dg/pr68319.f90: New test.

From-SVN: r230351

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/fortran/io.c
gcc/fortran/match.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr68319.f90 [new file with mode: 0644]

index b2c1d9bcb05b4a887ec6a6d9c7f2b2ea08e783d7..a455b6bf5311217f35df544f66d3d3b547f80b1e 100644 (file)
@@ -1,3 +1,10 @@
+2015-11-13  Steven G. Kargl  <kargl@gccc.gnu.org>
+
+       PR fortran/68319
+       * decl.c (gfc_match_data, gfc_match_entry): Enforce F2008:C1206.
+       * io.c (gfc_match_format): Ditto.
+       * match.c (gfc_match_st_function): Ditto.
+
 2015-11-13  David Malcolm  <dmalcolm@redhat.com>
 
        * error.c (gfc_warning): Pass line_table to rich_location ctor.
index c10557e968cf9902ba3366fb73970fa964041e95..6d76a7fd5aef0e88afcbb7b75e25dfba38bca4db 100644 (file)
@@ -552,6 +552,15 @@ gfc_match_data (void)
   gfc_data *new_data;
   match m;
 
+  /* Before parsing the rest of a DATA statement, check F2008:c1206.  */
+  if ((gfc_current_state () == COMP_FUNCTION
+       || gfc_current_state () == COMP_SUBROUTINE)
+      && gfc_state_stack->previous->state == COMP_INTERFACE)
+    {
+      gfc_error ("DATA statement at %C cannot appear within an INTERFACE");
+      return MATCH_ERROR;
+    }
+
   set_in_match_data (true);
 
   for (;;)
@@ -5767,6 +5776,13 @@ gfc_match_entry (void)
       return MATCH_ERROR;
     }
 
+  if ((state == COMP_SUBROUTINE || state == COMP_FUNCTION)
+      && gfc_state_stack->previous->state == COMP_INTERFACE)
+    {
+      gfc_error ("ENTRY statement at %C cannot appear within an INTERFACE");
+      return MATCH_ERROR;
+    }
+
   module_procedure = gfc_current_ns->parent != NULL
                   && gfc_current_ns->parent->proc_name
                   && gfc_current_ns->parent->proc_name->attr.flavor
index dbd02b35e54caec43b3ca5edb5231a33b2b42222..8cf952f95a800a6ec5b48081386a2316af90304a 100644 (file)
@@ -1199,6 +1199,15 @@ gfc_match_format (void)
       return MATCH_ERROR;
     }
 
+  /* Before parsing the rest of a FORMAT statement, check F2008:c1206.  */
+  if ((gfc_current_state () == COMP_FUNCTION
+       || gfc_current_state () == COMP_SUBROUTINE)
+      && gfc_state_stack->previous->state == COMP_INTERFACE)
+    {
+      gfc_error ("FORMAT statement at %C cannot appear within an INTERFACE");
+      return MATCH_ERROR;
+    }
+
   if (gfc_statement_label == NULL)
     {
       gfc_error ("Missing format label at %C");
index d4ba350ab5926d34642a30014e4f8ede500c3b10..22b0d7d42f725463a27ff74b560b8426458c3e29 100644 (file)
@@ -4913,6 +4913,15 @@ gfc_match_st_function (void)
 
   sym->value = expr;
 
+  if ((gfc_current_state () == COMP_FUNCTION
+       || gfc_current_state () == COMP_SUBROUTINE)
+      && gfc_state_stack->previous->state == COMP_INTERFACE)
+    {
+      gfc_error ("Statement function at %L cannot appear within an INTERFACE",
+                &expr->where);
+      return MATCH_ERROR;
+    }
+
   if (!gfc_notify_std (GFC_STD_F95_OBS, "Statement function at %C"))
     return MATCH_ERROR;
 
index deb1a712db2867d8bf0e3332709ebe19ab728015..e01d0c6fc171af4cdfab442ac2c7af2d0beb35e9 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-13  Steven G. Kargl  <kargl@gccc.gnu.org>
+
+       PR fortran/68319
+       * gfortran.dg/pr68319.f90: New test.
+
 2015-11-13  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        * gcc.target/powerpc/float128-hw.c: New test for IEEE 128-bit
diff --git a/gcc/testsuite/gfortran.dg/pr68319.f90 b/gcc/testsuite/gfortran.dg/pr68319.f90
new file mode 100644 (file)
index 0000000..941316d
--- /dev/null
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! PR fortran/68319
+!
+subroutine foo
+
+   interface
+
+      real function bar(i)
+         f(i) = 2 * i         ! { dg-error "cannot appear within" }
+      end function bar
+
+      real function bah(j)
+         entry boo(j)         ! { dg-error "cannot appear within" }
+      end function bah
+
+      real function fu(j)
+         data i /1/           ! { dg-error "cannot appear within" }
+      end function fu
+
+      real function fee(j)
+10       format('(A)')        ! { dg-error "cannot appear within" }
+      end function fee
+
+   end interface
+
+end subroutine foo