public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface
@ 2015-11-28 10:51 Paul Richard Thomas
  2015-11-28 16:29 ` Steve Kargl
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Richard Thomas @ 2015-11-28 10:51 UTC (permalink / raw)
  To: fortran, gcc-patches

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

Dear All,

The check that the number of formal arguments in the submodule
procedure declaration is the same as that in the module interface was
not working when there were none in either of them. This rather
trivial patch remedies the problem.

Bootstrapped and regtested on FC21/x86_64 - OK for trunk?

Paul


2015-11-28  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/68534
    * decl.c (gfc_match_formal_arglist): Cope with zero formal args
    either in interface declaration or in procedure declaration in
    submodule.

2015-11-28  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/68534
    * gfortran.dg/submodule_13.f08: New test.

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

Index: gcc/fortran/decl.c
===================================================================
*** gcc/fortran/decl.c	(revision 230783)
--- gcc/fortran/decl.c	(working copy)
*************** ok:
*** 4817,4830 ****
        goto cleanup;
      }
  
!   if (formal)
      {
        for (p = formal, q = head; p && q; p = p->next, q = q->next)
  	{
  	  if ((p->next != NULL && q->next == NULL)
  	      || (p->next == NULL && q->next != NULL))
! 	    gfc_error_now ("Mismatch in number of MODULE PROCEDURE "
! 		           "formal arguments at %C");
  	  else if ((p->sym == NULL && q->sym == NULL)
  		    || strcmp (p->sym->name, q->sym->name) == 0)
  	    continue;
--- 4817,4839 ----
        goto cleanup;
      }
  
!   if (progname->attr.module_procedure && progname->attr.host_assoc)
      {
+       bool arg_count_mismatch = false;
+ 
+       if (!formal && head)
+ 	arg_count_mismatch = true;
+ 
+       /* Abreviated module procedure declaration is not meant to have any
+ 	 formal arguments!  */
+       if (!sym->abr_modproc_decl && formal && !head)
+ 	arg_count_mismatch = true;
+ 
        for (p = formal, q = head; p && q; p = p->next, q = q->next)
  	{
  	  if ((p->next != NULL && q->next == NULL)
  	      || (p->next == NULL && q->next != NULL))
! 	    arg_count_mismatch = true;
  	  else if ((p->sym == NULL && q->sym == NULL)
  		    || strcmp (p->sym->name, q->sym->name) == 0)
  	    continue;
*************** ok:
*** 4833,4838 ****
--- 4842,4851 ----
  			   "argument names (%s/%s) at %C",
  			   p->sym->name, q->sym->name);
  	}
+ 
+       if (arg_count_mismatch)
+ 	gfc_error_now ("Mismatch in number of MODULE PROCEDURE "
+ 		       "formal arguments at %C");
      }
  
    return MATCH_YES;
Index: gcc/testsuite/gfortran.dg/submodule_13.f08
===================================================================
*** gcc/testsuite/gfortran.dg/submodule_13.f08	(revision 0)
--- gcc/testsuite/gfortran.dg/submodule_13.f08	(working copy)
***************
*** 0 ****
--- 1,32 ----
+ ! { dg-do compile }
+ !
+ ! Checks the fix for PR68534 in which checks for the number
+ ! failed if either the interface or the module procedure had
+ ! no dummies.
+ !
+ ! Reported on clf at:
+ ! https://groups.google.com/forum/#!topic/comp.lang.fortran/-ZgbM5qkFmc
+ !
+ module m
+   implicit none
+     interface
+       module subroutine foo()
+       end subroutine foo
+ 
+       module subroutine bar(i)
+         integer, intent(inout) :: i
+       end subroutine bar
+    end interface
+ end module m
+ 
+ submodule(m) sm
+ contains
+   module subroutine foo(i) ! { dg-error "Mismatch in number of MODULE PROCEDURE formal" }
+     integer, intent(inout) :: i
+     i = 42
+   end subroutine foo
+ 
+   module subroutine bar ! { dg-error "Mismatch in number of MODULE PROCEDURE formal" }
+     print *, "bar"
+   end subroutine bar
+ end submodule sm

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

* Re: [Patch, fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface
  2015-11-28 10:51 [Patch, fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface Paul Richard Thomas
@ 2015-11-28 16:29 ` Steve Kargl
  2015-11-30 13:38   ` Paul Richard Thomas
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Kargl @ 2015-11-28 16:29 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: fortran, gcc-patches

On Sat, Nov 28, 2015 at 11:35:54AM +0100, Paul Richard Thomas wrote:
> + 
> +       /* Abreviated module procedure declaration is not meant to have any

s/Abreviated/Abbreviated

> + 	 formal arguments!  */
> +       if (!sym->abr_modproc_decl && formal && !head)
> + 	arg_count_mismatch = true;
> + 

OK to commit.

-- 
Steve

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

* Re: [Patch, fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface
  2015-11-28 16:29 ` Steve Kargl
@ 2015-11-30 13:38   ` Paul Richard Thomas
  2015-12-03  6:02     ` Steve Kargl
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Richard Thomas @ 2015-11-30 13:38 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches

Committed as revision 231072.

Thanks for the review

Paul

On 28 November 2015 at 17:19, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
> On Sat, Nov 28, 2015 at 11:35:54AM +0100, Paul Richard Thomas wrote:
>> +
>> +       /* Abreviated module procedure declaration is not meant to have any
>
> s/Abreviated/Abbreviated
>
>> +      formal arguments!  */
>> +       if (!sym->abr_modproc_decl && formal && !head)
>> +     arg_count_mismatch = true;
>> +
>
> OK to commit.
>
> --
> Steve



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx

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

* Re: [Patch, fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface
  2015-11-30 13:38   ` Paul Richard Thomas
@ 2015-12-03  6:02     ` Steve Kargl
  2015-12-03  6:26       ` Steve Kargl
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Kargl @ 2015-12-03  6:02 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: fortran, gcc-patches

Paul,

I'm stumped.  Something is broken on i386-*-freebsd. :-(

Running /mnt/kargl/gcc/gcc/testsuite/gfortran.dg/dg.exp ...
FAIL: gfortran.dg/submodule_10.f08   -O  (internal compiler error)
FAIL: gfortran.dg/submodule_10.f08   -O  (test for excess errors)
FAIL: gfortran.dg/submodule_11.f08   -O0  (internal compiler error)
FAIL: gfortran.dg/submodule_11.f08   -O0  (test for excess errors)
FAIL: gfortran.dg/submodule_11.f08   -O1  (internal compiler error)
FAIL: gfortran.dg/submodule_11.f08   -O1  (test for excess errors)
FAIL: gfortran.dg/submodule_11.f08   -O2  (internal compiler error)
FAIL: gfortran.dg/submodule_11.f08   -O2  (test for excess errors)
FAIL: gfortran.dg/submodule_11.f08   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (internal compiler error)
FAIL: gfortran.dg/submodule_11.f08   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
FAIL: gfortran.dg/submodule_11.f08   -O3 -g  (internal compiler error)
FAIL: gfortran.dg/submodule_11.f08   -O3 -g  (test for excess errors)
FAIL: gfortran.dg/submodule_11.f08   -Os  (internal compiler error)
FAIL: gfortran.dg/submodule_11.f08   -Os  (test for excess errors)
FAIL: gfortran.dg/submodule_13.f08   -O  (internal compiler error)
FAIL: gfortran.dg/submodule_13.f08   -O   (test for errors, line 29)
FAIL: gfortran.dg/submodule_13.f08   -O  (test for excess errors)

Using valgrind on 'f951 submodule_10.f08' yields

laptop-kargl:kargl[324] valgrind ~/work/libexec/gcc/i386-unknown-freebsd11.0/6.0.0/f951 submodule_10.f08
==74201== Memcheck, a memory error detector
==74201== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==74201== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==74201== Command: /home/kargl/work/libexec/gcc/i386-unknown-freebsd11.0/6.0.0/f951 submodule_10.f08
==74201== 
==74201== Use of uninitialised value of size 4
==74201==    at 0x81DC20C: gfc_match_formal_arglist(gfc_symbol*, int, int) (decl.c:4829)
==74201==    by 0x81DE6F7: gfc_match_subroutine() (decl.c:6016)
==74201==    by 0x8248FC0: decode_statement() (parse.c:378)
==74201==    by 0x8247844: next_free (parse.c:1076)
==74201==    by 0x8247844: next_statement() (parse.c:1310)
==74201==    by 0x8258ACC: parse_contained(int) (parse.c:5038)
==74201==    by 0x824870F: parse_module() (parse.c:5431)
==74201==    by 0x82467D4: gfc_parse_file() (parse.c:5729)
==74201==    by 0x82972E7: gfc_be_parse_file() (f95-lang.c:201)
==74201==    by 0x87E4787: compile_file() (toplev.c:464)
==74201==    by 0x87E43E4: do_compile (toplev.c:1951)
==74201==    by 0x87E43E4: toplev::main(int, char**) (toplev.c:2058)
==74201==    by 0x8FCC00D: main (main.c:39)
==74201== 
==74201== Invalid read of size 1
==74201==    at 0x81DC20C: gfc_match_formal_arglist(gfc_symbol*, int, int) (decl.==74201==    at 0x81DC20C: gfc_match_formal_arglist(gfc_symbol*, int, int) (decl.c:4829)
==74201==    by 0x81DE6F7: gfc_match_subroutine() (decl.c:6016)
==74201==    by 0x8248FC0: decode_statement() (parse.c:378)
==74201==    by 0x8247844: next_free (parse.c:1076)
==74201==    by 0x8247844: next_statement() (parse.c:1310)
==74201==    by 0x8258ACC: parse_contained(int) (parse.c:5038)
==74201==    by 0x824870F: parse_module() (parse.c:5431)
==74201==    by 0x82467D4: gfc_parse_file() (parse.c:5729)
==74201==    by 0x82972E7: gfc_be_parse_file() (f95-lang.c:201)
==74201==    by 0x87E4787: compile_file() (toplev.c:464)
==74201==    by 0x87E43E4: do_compile (toplev.c:1951)
==74201==    by 0x87E43E4: toplev::main(int, char**) (toplev.c:2058)
==74201==    by 0x8FCC00D: main (main.c:39)
==74201==  Address 0x8094 is not stack'd, malloc'd or (recently) free'd
==74201== 


I suspect that we have a sym=NULL dereferenc someplace.

-- 
steve


On Mon, Nov 30, 2015 at 02:35:35PM +0100, Paul Richard Thomas wrote:
> Committed as revision 231072.
> 
> Thanks for the review
> 
> Paul
> 
> On 28 November 2015 at 17:19, Steve Kargl
> <sgk@troutmask.apl.washington.edu> wrote:
> > On Sat, Nov 28, 2015 at 11:35:54AM +0100, Paul Richard Thomas wrote:
> >> +
> >> +       /* Abreviated module procedure declaration is not meant to have any
> >
> > s/Abreviated/Abbreviated
> >
> >> +      formal arguments!  */
> >> +       if (!sym->abr_modproc_decl && formal && !head)
> >> +     arg_count_mismatch = true;
> >> +
> >
> > OK to commit.
> >
> > --
> > Steve
> 
> 
> 
> -- 
> Outside of a dog, a book is a man's best friend. Inside of a dog it's
> too dark to read.
> 
> Groucho Marx

-- 
Steve

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

* Re: [Patch, fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface
  2015-12-03  6:02     ` Steve Kargl
@ 2015-12-03  6:26       ` Steve Kargl
  2015-12-03  6:43         ` Steve Kargl
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Kargl @ 2015-12-03  6:26 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: fortran, gcc-patches

On Wed, Dec 02, 2015 at 10:02:33PM -0800, Steve Kargl wrote:
> Paul,
> 
> I'm stumped.  Something is broken on i386-*-freebsd. :-(
> 
> Running /mnt/kargl/gcc/gcc/testsuite/gfortran.dg/dg.exp ...
> FAIL: gfortran.dg/submodule_10.f08   -O  (internal compiler error)
> FAIL: gfortran.dg/submodule_10.f08   -O  (test for excess errors)
> FAIL: gfortran.dg/submodule_11.f08   -O0  (internal compiler error)
> FAIL: gfortran.dg/submodule_11.f08   -O0  (test for excess errors)
> FAIL: gfortran.dg/submodule_11.f08   -O1  (internal compiler error)
> FAIL: gfortran.dg/submodule_11.f08   -O1  (test for excess errors)
> FAIL: gfortran.dg/submodule_11.f08   -O2  (internal compiler error)
> FAIL: gfortran.dg/submodule_11.f08   -O2  (test for excess errors)
> FAIL: gfortran.dg/submodule_11.f08   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (internal compiler error)
> FAIL: gfortran.dg/submodule_11.f08   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
> FAIL: gfortran.dg/submodule_11.f08   -O3 -g  (internal compiler error)
> FAIL: gfortran.dg/submodule_11.f08   -O3 -g  (test for excess errors)
> FAIL: gfortran.dg/submodule_11.f08   -Os  (internal compiler error)
> FAIL: gfortran.dg/submodule_11.f08   -Os  (test for excess errors)

Well, if I change the order of the conditionals decl.c:4831, I 
can get rid of the above FAILs.

Index: decl.c
===================================================================
--- decl.c      (revision 231219)
+++ decl.c      (working copy)
@@ -4826,7 +4826,7 @@ ok:
 
       /* Abbreviated module procedure declaration is not meant to have any
         formal arguments!  */
-      if (!sym->abr_modproc_decl && formal && !head)
+      if (formal && !head && sym && !sym->abr_modproc_decl)
        arg_count_mismatch = true;
 
       for (p = formal, q = head; p && q; p = p->next, q = q->next)

-- 
steve

> FAIL: gfortran.dg/submodule_13.f08   -O  (internal compiler error)
> FAIL: gfortran.dg/submodule_13.f08   -O   (test for errors, line 29)
> FAIL: gfortran.dg/submodule_13.f08   -O  (test for excess errors)
> 
> Using valgrind on 'f951 submodule_10.f08' yields
> 
> laptop-kargl:kargl[324] valgrind ~/work/libexec/gcc/i386-unknown-freebsd11.0/6.0.0/f951 submodule_10.f08
> ==74201== Memcheck, a memory error detector
> ==74201== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
> ==74201== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
> ==74201== Command: /home/kargl/work/libexec/gcc/i386-unknown-freebsd11.0/6.0.0/f951 submodule_10.f08
> ==74201== 
> ==74201== Use of uninitialised value of size 4
> ==74201==    at 0x81DC20C: gfc_match_formal_arglist(gfc_symbol*, int, int) (decl.c:4829)
> ==74201==    by 0x81DE6F7: gfc_match_subroutine() (decl.c:6016)
> ==74201==    by 0x8248FC0: decode_statement() (parse.c:378)
> ==74201==    by 0x8247844: next_free (parse.c:1076)
> ==74201==    by 0x8247844: next_statement() (parse.c:1310)
> ==74201==    by 0x8258ACC: parse_contained(int) (parse.c:5038)
> ==74201==    by 0x824870F: parse_module() (parse.c:5431)
> ==74201==    by 0x82467D4: gfc_parse_file() (parse.c:5729)
> ==74201==    by 0x82972E7: gfc_be_parse_file() (f95-lang.c:201)
> ==74201==    by 0x87E4787: compile_file() (toplev.c:464)
> ==74201==    by 0x87E43E4: do_compile (toplev.c:1951)
> ==74201==    by 0x87E43E4: toplev::main(int, char**) (toplev.c:2058)
> ==74201==    by 0x8FCC00D: main (main.c:39)
> ==74201== 
> ==74201== Invalid read of size 1
> ==74201==    at 0x81DC20C: gfc_match_formal_arglist(gfc_symbol*, int, int) (decl.==74201==    at 0x81DC20C: gfc_match_formal_arglist(gfc_symbol*, int, int) (decl.c:4829)
> ==74201==    by 0x81DE6F7: gfc_match_subroutine() (decl.c:6016)
> ==74201==    by 0x8248FC0: decode_statement() (parse.c:378)
> ==74201==    by 0x8247844: next_free (parse.c:1076)
> ==74201==    by 0x8247844: next_statement() (parse.c:1310)
> ==74201==    by 0x8258ACC: parse_contained(int) (parse.c:5038)
> ==74201==    by 0x824870F: parse_module() (parse.c:5431)
> ==74201==    by 0x82467D4: gfc_parse_file() (parse.c:5729)
> ==74201==    by 0x82972E7: gfc_be_parse_file() (f95-lang.c:201)
> ==74201==    by 0x87E4787: compile_file() (toplev.c:464)
> ==74201==    by 0x87E43E4: do_compile (toplev.c:1951)
> ==74201==    by 0x87E43E4: toplev::main(int, char**) (toplev.c:2058)
> ==74201==    by 0x8FCC00D: main (main.c:39)
> ==74201==  Address 0x8094 is not stack'd, malloc'd or (recently) free'd
> ==74201== 
> 
> 
> I suspect that we have a sym=NULL dereferenc someplace.
> 
> -- 
> steve
> 
> 
> On Mon, Nov 30, 2015 at 02:35:35PM +0100, Paul Richard Thomas wrote:
> > Committed as revision 231072.
> > 
> > Thanks for the review
> > 
> > Paul
> > 
> > On 28 November 2015 at 17:19, Steve Kargl
> > <sgk@troutmask.apl.washington.edu> wrote:
> > > On Sat, Nov 28, 2015 at 11:35:54AM +0100, Paul Richard Thomas wrote:
> > >> +
> > >> +       /* Abreviated module procedure declaration is not meant to have any
> > >
> > > s/Abreviated/Abbreviated
> > >
> > >> +      formal arguments!  */
> > >> +       if (!sym->abr_modproc_decl && formal && !head)
> > >> +     arg_count_mismatch = true;
> > >> +
> > >
> > > OK to commit.
> > >
> > > --
> > > Steve
> > 
> > 
> > 
> > -- 
> > Outside of a dog, a book is a man's best friend. Inside of a dog it's
> > too dark to read.
> > 
> > Groucho Marx
> 
> -- 
> Steve

-- 
Steve

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

* Re: [Patch, fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface
  2015-12-03  6:26       ` Steve Kargl
@ 2015-12-03  6:43         ` Steve Kargl
  2015-12-03 11:31           ` Paul Richard Thomas
       [not found]           ` <CAGkQGiLhWmeCGXnGn_2_h8tWNQREq6Mt=F4Dc5SqJdoHA0pppw@mail.gmail.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Steve Kargl @ 2015-12-03  6:43 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: fortran, gcc-patches

On Wed, Dec 02, 2015 at 10:26:30PM -0800, Steve Kargl wrote:
> On Wed, Dec 02, 2015 at 10:02:33PM -0800, Steve Kargl wrote:
> > Paul,
> > 
> > I'm stumped.  Something is broken on i386-*-freebsd. :-(
> > 
> > Running /mnt/kargl/gcc/gcc/testsuite/gfortran.dg/dg.exp ...
> > FAIL: gfortran.dg/submodule_10.f08   -O  (internal compiler error)
> > FAIL: gfortran.dg/submodule_10.f08   -O  (test for excess errors)
> > FAIL: gfortran.dg/submodule_11.f08   -O0  (internal compiler error)
> > FAIL: gfortran.dg/submodule_11.f08   -O0  (test for excess errors)
> > FAIL: gfortran.dg/submodule_11.f08   -O1  (internal compiler error)
> > FAIL: gfortran.dg/submodule_11.f08   -O1  (test for excess errors)
> > FAIL: gfortran.dg/submodule_11.f08   -O2  (internal compiler error)
> > FAIL: gfortran.dg/submodule_11.f08   -O2  (test for excess errors)
> > FAIL: gfortran.dg/submodule_11.f08   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (internal compiler error)
> > FAIL: gfortran.dg/submodule_11.f08   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
> > FAIL: gfortran.dg/submodule_11.f08   -O3 -g  (internal compiler error)
> > FAIL: gfortran.dg/submodule_11.f08   -O3 -g  (test for excess errors)
> > FAIL: gfortran.dg/submodule_11.f08   -Os  (internal compiler error)
> > FAIL: gfortran.dg/submodule_11.f08   -Os  (test for excess errors)
> 
> Well, if I change the order of the conditionals decl.c:4831, I 
> can get rid of the above FAILs.
> 
> Index: decl.c
> ===================================================================
> --- decl.c      (revision 231219)
> +++ decl.c      (working copy)
> @@ -4826,7 +4826,7 @@ ok:
>  
>        /* Abbreviated module procedure declaration is not meant to have any
>          formal arguments!  */
> -      if (!sym->abr_modproc_decl && formal && !head)
> +      if (formal && !head && sym && !sym->abr_modproc_decl)
>         arg_count_mismatch = true;
>  
>        for (p = formal, q = head; p && q; p = p->next, q = q->next)
> 
> -- 
> steve
> 
> > FAIL: gfortran.dg/submodule_13.f08   -O  (internal compiler error)
> > FAIL: gfortran.dg/submodule_13.f08   -O   (test for errors, line 29)
> > FAIL: gfortran.dg/submodule_13.f08   -O  (test for excess errors)

These ICEs persist at line 4831.  In looking at the code, I'm
now somewhat unsure what it should be doing.  In particular, 
there are 2 gfc_error_now() calls in the below:


      for (p = formal, q = head; p && q; p = p->next, q = q->next)
	{
	  if ((p->next != NULL && q->next == NULL)
	      || (p->next == NULL && q->next != NULL))
	    arg_count_mismatch = true;
	  else if ((p->sym == NULL && q->sym == NULL)
		    || strcmp (p->sym->name, q->sym->name) == 0)
	    continue;
	  else
	    gfc_error_now ("Mismatch in MODULE PROCEDURE formal "
			   "argument names (%s/%s) at %C",
			   p->sym->name, q->sym->name);
	}

      if (arg_count_mismatch)
	  gfc_error_now ("Mismatch in number of MODULE PROCEDURE "
			 "formal arguments at %C");
    }

  return MATCH_YES;

cleanup:
  gfc_free_formal_arglist (head);
  return m;

But, we return MATCH_YES?  I would expect setting m = MATCH_ERROR
and jumping to cleanup.  That's ugly.

-- 
Steve

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

* Re: [Patch, fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface
  2015-12-03  6:43         ` Steve Kargl
@ 2015-12-03 11:31           ` Paul Richard Thomas
       [not found]           ` <CAGkQGiLhWmeCGXnGn_2_h8tWNQREq6Mt=F4Dc5SqJdoHA0pppw@mail.gmail.com>
  1 sibling, 0 replies; 8+ messages in thread
From: Paul Richard Thomas @ 2015-12-03 11:31 UTC (permalink / raw)
  To: Steve Kargl; +Cc: fortran, gcc-patches

Dear Steve,

I'll take a look at this this afternoon. Thanks for bringing it to my attention.

Cheers

Paul

On 3 December 2015 at 07:43, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
> On Wed, Dec 02, 2015 at 10:26:30PM -0800, Steve Kargl wrote:
>> On Wed, Dec 02, 2015 at 10:02:33PM -0800, Steve Kargl wrote:
>> > Paul,
>> >
>> > I'm stumped.  Something is broken on i386-*-freebsd. :-(
>> >
>> > Running /mnt/kargl/gcc/gcc/testsuite/gfortran.dg/dg.exp ...
>> > FAIL: gfortran.dg/submodule_10.f08   -O  (internal compiler error)
>> > FAIL: gfortran.dg/submodule_10.f08   -O  (test for excess errors)
>> > FAIL: gfortran.dg/submodule_11.f08   -O0  (internal compiler error)
>> > FAIL: gfortran.dg/submodule_11.f08   -O0  (test for excess errors)
>> > FAIL: gfortran.dg/submodule_11.f08   -O1  (internal compiler error)
>> > FAIL: gfortran.dg/submodule_11.f08   -O1  (test for excess errors)
>> > FAIL: gfortran.dg/submodule_11.f08   -O2  (internal compiler error)
>> > FAIL: gfortran.dg/submodule_11.f08   -O2  (test for excess errors)
>> > FAIL: gfortran.dg/submodule_11.f08   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (internal compiler error)
>> > FAIL: gfortran.dg/submodule_11.f08   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
>> > FAIL: gfortran.dg/submodule_11.f08   -O3 -g  (internal compiler error)
>> > FAIL: gfortran.dg/submodule_11.f08   -O3 -g  (test for excess errors)
>> > FAIL: gfortran.dg/submodule_11.f08   -Os  (internal compiler error)
>> > FAIL: gfortran.dg/submodule_11.f08   -Os  (test for excess errors)
>>
>> Well, if I change the order of the conditionals decl.c:4831, I
>> can get rid of the above FAILs.
>>
>> Index: decl.c
>> ===================================================================
>> --- decl.c      (revision 231219)
>> +++ decl.c      (working copy)
>> @@ -4826,7 +4826,7 @@ ok:
>>
>>        /* Abbreviated module procedure declaration is not meant to have any
>>          formal arguments!  */
>> -      if (!sym->abr_modproc_decl && formal && !head)
>> +      if (formal && !head && sym && !sym->abr_modproc_decl)
>>         arg_count_mismatch = true;
>>
>>        for (p = formal, q = head; p && q; p = p->next, q = q->next)
>>
>> --
>> steve
>>
>> > FAIL: gfortran.dg/submodule_13.f08   -O  (internal compiler error)
>> > FAIL: gfortran.dg/submodule_13.f08   -O   (test for errors, line 29)
>> > FAIL: gfortran.dg/submodule_13.f08   -O  (test for excess errors)
>
> These ICEs persist at line 4831.  In looking at the code, I'm
> now somewhat unsure what it should be doing.  In particular,
> there are 2 gfc_error_now() calls in the below:
>
>
>       for (p = formal, q = head; p && q; p = p->next, q = q->next)
>         {
>           if ((p->next != NULL && q->next == NULL)
>               || (p->next == NULL && q->next != NULL))
>             arg_count_mismatch = true;
>           else if ((p->sym == NULL && q->sym == NULL)
>                     || strcmp (p->sym->name, q->sym->name) == 0)
>             continue;
>           else
>             gfc_error_now ("Mismatch in MODULE PROCEDURE formal "
>                            "argument names (%s/%s) at %C",
>                            p->sym->name, q->sym->name);
>         }
>
>       if (arg_count_mismatch)
>           gfc_error_now ("Mismatch in number of MODULE PROCEDURE "
>                          "formal arguments at %C");
>     }
>
>   return MATCH_YES;
>
> cleanup:
>   gfc_free_formal_arglist (head);
>   return m;
>
> But, we return MATCH_YES?  I would expect setting m = MATCH_ERROR
> and jumping to cleanup.  That's ugly.
>
> --
> Steve



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx

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

* Re: [Patch, fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface
       [not found]             ` <20151205164137.GA20634@troutmask.apl.washington.edu>
@ 2015-12-05 17:25               ` Paul Richard Thomas
  0 siblings, 0 replies; 8+ messages in thread
From: Paul Richard Thomas @ 2015-12-05 17:25 UTC (permalink / raw)
  To: Steve Kargl, gcc-patches; +Cc: fortran

Committed revision as 231319.

Thanks for testing the patch.

Paul

On 5 December 2015 at 17:41, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
> On Sat, Dec 05, 2015 at 04:20:54PM +0100, Paul Richard Thomas wrote:
>>
>> The cause of the segfault, I believe, was an error: 'sym' being used
>> instead of 'progname': Could you please try the attached patch when
>> you have a moment.
>
> Patch fixes the issue of i386-*-freebsd.  Thanks for the
> prompt fix.  OK to commit (with ChangeLog, of course).
>
> --
> Steve



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx

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

end of thread, other threads:[~2015-12-05 17:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-28 10:51 [Patch, fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface Paul Richard Thomas
2015-11-28 16:29 ` Steve Kargl
2015-11-30 13:38   ` Paul Richard Thomas
2015-12-03  6:02     ` Steve Kargl
2015-12-03  6:26       ` Steve Kargl
2015-12-03  6:43         ` Steve Kargl
2015-12-03 11:31           ` Paul Richard Thomas
     [not found]           ` <CAGkQGiLhWmeCGXnGn_2_h8tWNQREq6Mt=F4Dc5SqJdoHA0pppw@mail.gmail.com>
     [not found]             ` <20151205164137.GA20634@troutmask.apl.washington.edu>
2015-12-05 17:25               ` 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).