public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR79447 - [F08] gfortran rejects valid & accepts invalid internal subprogram in a submodule
@ 2017-02-15 18:01 Paul Richard Thomas
  2017-02-16  0:37 ` Jerry DeLisle
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2017-02-15 18:01 UTC (permalink / raw)
  To: fortran, gcc-patches; +Cc: Damian Rouson

[-- Attachment #1: Type: text/plain, Size: 542 bytes --]

Dear All,

This patch is straightforward, verging on 'obvious'.

Bootstraps and regtests on FC23/x86_64 - OK for trunk and 6 branch?

Cheers

Paul

2017-02-15  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-15  Paul Thomas  <pault@gcc.gnu.org>

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

[-- Attachment #2: submit.diff --]
[-- Type: text/plain, Size: 2980 bytes --]

Index: gcc/fortran/decl.c
===================================================================
*** gcc/fortran/decl.c	(revision 245196)
--- gcc/fortran/decl.c	(working copy)
*************** gfc_set_constant_character_len (int len,
*** 1499,1505 ****
  
    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);
--- 1499,1505 ----
  
    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);
*************** gfc_match_end (gfc_statement *st)
*** 6756,6762 ****
    match m;
    gfc_namespace *parent_ns, *ns, *prev_ns;
    gfc_namespace **nsp;
!   bool abreviated_modproc_decl;
    bool got_matching_end = false;
  
    old_loc = gfc_current_locus;
--- 6756,6762 ----
    match m;
    gfc_namespace *parent_ns, *ns, *prev_ns;
    gfc_namespace **nsp;
!   bool abreviated_modproc_decl = false;
    bool got_matching_end = false;
  
    old_loc = gfc_current_locus;
*************** gfc_match_end (gfc_statement *st)
*** 6780,6794 ****
        state = gfc_state_stack->previous->state;
        block_name = gfc_state_stack->previous->sym == NULL
  		 ? NULL : gfc_state_stack->previous->sym->name;
        break;
  
      default:
        break;
      }
  
!   abreviated_modproc_decl
! 	= gfc_current_block ()
! 	  && gfc_current_block ()->abr_modproc_decl;
  
    switch (state)
      {
--- 6780,6796 ----
        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;
      }
  
!   if (!abreviated_modproc_decl)
!     abreviated_modproc_decl = gfc_current_block ()
! 			      && gfc_current_block ()->abr_modproc_decl;
  
    switch (state)
      {
Index: gcc/testsuite/gfortran.dg/submodule_24.f08
===================================================================
*** gcc/testsuite/gfortran.dg/submodule_24.f08	(nonexistent)
--- gcc/testsuite/gfortran.dg/submodule_24.f08	(working copy)
***************
*** 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, fortran] PR79447 - [F08] gfortran rejects valid & accepts invalid internal subprogram in a submodule
  2017-02-15 18:01 [Patch, fortran] PR79447 - [F08] gfortran rejects valid & accepts invalid internal subprogram in a submodule Paul Richard Thomas
@ 2017-02-16  0:37 ` Jerry DeLisle
  2017-02-19 20:00   ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Jerry DeLisle @ 2017-02-16  0:37 UTC (permalink / raw)
  To: Paul Richard Thomas, fortran, gcc-patches; +Cc: Damian Rouson

On 02/15/2017 10:01 AM, Paul Richard Thomas wrote:
> Dear All,
> 
> This patch is straightforward, verging on 'obvious'.
> 
> Bootstraps and regtests on FC23/x86_64 - OK for trunk and 6 branch?
> 
Yes, OK

Jerry

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, fortran] PR79447 - [F08] gfortran rejects valid & accepts invalid internal subprogram in a submodule
  2017-02-16  0:37 ` Jerry DeLisle
@ 2017-02-19 20:00   ` Paul Richard Thomas
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Richard Thomas @ 2017-02-19 20:00 UTC (permalink / raw)
  To: Jerry DeLisle; +Cc: fortran, gcc-patches, Damian Rouson

Hi Jerry,

Committed as revision 245582.

Thanks for the review.

Paul

On 16 February 2017 at 00:37, Jerry DeLisle <jvdelisle@charter.net> wrote:
> On 02/15/2017 10:01 AM, Paul Richard Thomas wrote:
>> Dear All,
>>
>> This patch is straightforward, verging on 'obvious'.
>>
>> Bootstraps and regtests on FC23/x86_64 - OK for trunk and 6 branch?
>>
> Yes, OK
>
> Jerry



-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-19 20:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-15 18:01 [Patch, fortran] PR79447 - [F08] gfortran rejects valid & accepts invalid internal subprogram in a submodule Paul Richard Thomas
2017-02-16  0:37 ` Jerry DeLisle
2017-02-19 20:00   ` Paul Richard Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).