diff mbox

[fortran] PR68534 - No error on mismatch in number of arguments between submodule and module interface

Message ID 20151203062630.GA62157@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl Dec. 3, 2015, 6:26 a.m. UTC
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.

Comments

Steve Kargl Dec. 3, 2015, 6:43 a.m. UTC | #1
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.
Paul Richard Thomas Dec. 3, 2015, 11:31 a.m. UTC | #2
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
Paul Richard Thomas Dec. 5, 2015, 5:25 p.m. UTC | #3
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
diff mbox

Patch

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)