re PR fortran/79447 ([F08] gfortran rejects valid & accepts invalid internal subprogr...
authorPaul Thomas <pault@gcc.gnu.org>
Sun, 19 Feb 2017 19:59:20 +0000 (19:59 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sun, 19 Feb 2017 19:59:20 +0000 (19:59 +0000)
2017-02-19  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/79447
* decl.c (gfc_set_constant_character_len): Whitespace.
(gfc_match_end): Catch case where a procedure is contained in
a module procedure and ensure that 'end procedure' is the
correct termination.

2017-02-19  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/79447
* gfortran.dg/submodule_24.f08 : New test.

From-SVN: r245582

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/submodule_24.f08 [new file with mode: 0644]

index 3dfbbc5ed5b4d4bd85198b1a425f2d1e5f03edb3..fb7123472d7a8fb18f272a47b06470ade88719d7 100644 (file)
@@ -1,4 +1,12 @@
-017-02-19  Paul Thomas  <pault@gcc.gnu.org>
+2017-02-19  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/79447
+       * decl.c (gfc_set_constant_character_len): Whitespace.
+       (gfc_match_end): Catch case where a procedure is contained in
+       a module procedure and ensure that 'end procedure' is the
+       correct termination.
+
+2017-02-19  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/79402
        * resolve.c (fixup_unique_dummy): New function.
index a92e06aa6fc1e17f215a2a3c08939f5106205433..d3e7e84236e8452ec12860ef857ed4453dd25dc2 100644 (file)
@@ -1499,7 +1499,7 @@ gfc_set_constant_character_len (int len, gfc_expr *expr, int check_len)
 
   if (expr->ts.type != BT_CHARACTER)
     return;
+
   if (expr->expr_type != EXPR_CONSTANT)
     {
       gfc_error_now ("CHARACTER length must be a constant at %L", &expr->where);
@@ -6756,7 +6756,7 @@ gfc_match_end (gfc_statement *st)
   match m;
   gfc_namespace *parent_ns, *ns, *prev_ns;
   gfc_namespace **nsp;
-  bool abreviated_modproc_decl;
+  bool abreviated_modproc_decl = false;
   bool got_matching_end = false;
 
   old_loc = gfc_current_locus;
@@ -6780,15 +6780,17 @@ gfc_match_end (gfc_statement *st)
       state = gfc_state_stack->previous->state;
       block_name = gfc_state_stack->previous->sym == NULL
                 ? NULL : gfc_state_stack->previous->sym->name;
+      abreviated_modproc_decl = gfc_state_stack->previous->sym
+               && gfc_state_stack->previous->sym->abr_modproc_decl;
       break;
 
     default:
       break;
     }
 
-  abreviated_modproc_decl
-       = gfc_current_block ()
-         && gfc_current_block ()->abr_modproc_decl;
+  if (!abreviated_modproc_decl)
+    abreviated_modproc_decl = gfc_current_block ()
+                             && gfc_current_block ()->abr_modproc_decl;
 
   switch (state)
     {
index eb74a459abfe60e20e1fce04f6a8e5eef5c1f80f..1f6f9671022560828aa65d871d59eb61a24c3fb1 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-19  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/79447
+       * gfortran.dg/submodule_24.f08 : New test.
+
 2017-02-19  Andre Vehreschild  <vehre@gcc.gnu.org>
 
        PR fortran/79229
diff --git a/gcc/testsuite/gfortran.dg/submodule_24.f08 b/gcc/testsuite/gfortran.dg/submodule_24.f08
new file mode 100644 (file)
index 0000000..88b40fd
--- /dev/null
@@ -0,0 +1,23 @@
+! { dg-do compile }
+! Test the fix for PR79447, in which the END PROCEDURE statement
+! for MODULE PROCEDURE foo was not accepted.
+!
+! Contributed by Damian Rouson  <damian@sourceryinstitute.org>
+!
+module foo_interface
+  implicit none
+  interface
+    module subroutine foo()
+    end subroutine
+  end interface
+end module foo_interface
+
+submodule(foo_interface) foo_implementation
+contains
+    module procedure foo
+    contains
+      module subroutine bar()
+      end subroutine
+    end procedure
+   !end subroutine ! gfortran accepted this invalid workaround
+end submodule