diff mbox

[Fortran,Regression] PR 60231: ICE on undefined generic

Message ID CAKwh3qi268Z1HC142FXML1vMk61Cy64p85C4gOSZijBr5txYiQ@mail.gmail.com
State New
Headers show

Commit Message

Janus Weil Feb. 17, 2014, 2:41 p.m. UTC
Hi all,

attached is a patch for an ICE-on-invalid problem with generics: We
simply don't check if any dummy args are present.

Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.8?

Cheers,
Janus


2014-02-17  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/60231
    * resolve.c (check_generic_tbp_ambiguity): Check for presence of dummy
    arguments to prevent ICE.


2014-02-17  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/60231
    * gfortran.dg/typebound_generic_15.f90: New.

Comments

Tobias Burnus Feb. 17, 2014, 8:36 p.m. UTC | #1
Janus Weil wrote:
> attached is a patch for an ICE-on-invalid problem with generics: We
> simply don't check if any dummy args are present.

There is something odd with your test case - and possibly with the 
patch. You state that this is an ICE-on-invalid problem; however, I do 
not see a dg-error in your test case.

Tobias

> Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.8?
>
> Cheers,
> Janus
>
>
> 2014-02-17  Janus Weil  <janus@gcc.gnu.org>
>
>      PR fortran/60231
>      * resolve.c (check_generic_tbp_ambiguity): Check for presence of dummy
>      arguments to prevent ICE.
>
>
> 2014-02-17  Janus Weil  <janus@gcc.gnu.org>
>
>      PR fortran/60231
>      * gfortran.dg/typebound_generic_15.f90: New.
Janus Weil Feb. 17, 2014, 8:51 p.m. UTC | #2
2014-02-17 21:36 GMT+01:00 Tobias Burnus <burnus@net-b.de>:
> Janus Weil wrote:
>>
>> attached is a patch for an ICE-on-invalid problem with generics: We
>> simply don't check if any dummy args are present.
>
> There is something odd with your test case - and possibly with the patch.
> You state that this is an ICE-on-invalid problem; however, I do not see a
> dg-error in your test case.

Oh yes, sorry. I simply forgot the dg-errors. Thanks for noticing.
Updated test cases attached.

The errors one gets with the patch (as with 4.7) are the following:


typebound_generic_15.f90:13.21:

    generic :: Add => Add1, Add2  ! { dg-error "are ambiguous" }
                     1
Error: 'add1' and 'add2' for GENERIC 'add' at (1) are ambiguous
typebound_generic_15.f90:11.13:

    procedure :: Add1             ! { dg-error "must be a module procedure" }
             1
Error: 'add1' must be a module procedure or an external procedure with
an explicit interface at (1)
typebound_generic_15.f90:12.13:

    procedure :: Add2             ! { dg-error "must be a module procedure" }
             1
Error: 'add2' must be a module procedure or an external procedure with
an explicit interface at (1)


You think there's also something wrong with the patch?

Cheers,
Janus



>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.8?
>>
>> Cheers,
>> Janus
>>
>>
>> 2014-02-17  Janus Weil  <janus@gcc.gnu.org>
>>
>>      PR fortran/60231
>>      * resolve.c (check_generic_tbp_ambiguity): Check for presence of
>> dummy
>>      arguments to prevent ICE.
>>
>>
>> 2014-02-17  Janus Weil  <janus@gcc.gnu.org>
>>
>>      PR fortran/60231
>>      * gfortran.dg/typebound_generic_15.f90: New.
>
>
Tobias Burnus Feb. 18, 2014, 6:56 a.m. UTC | #3
Am 17.02.2014 21:51, schrieb Janus Weil:
> 2014-02-17 21:36 GMT+01:00 Tobias Burnus <burnus@net-b.de>:
>> Janus Weil wrote:
>>> attached is a patch for an ICE-on-invalid problem with generics: We
>>> simply don't check if any dummy args are present.
>> There is something odd with your test case - and possibly with the patch.
>> You state that this is an ICE-on-invalid problem; however, I do not see a
>> dg-error in your test case.
> Oh yes, sorry. I simply forgot the dg-errors. Thanks for noticing.
> Updated test cases attached.

That way, it makes more sense. I have now also looked at your patch and 
it is OK. Thanks!

Tobias


>
> The errors one gets with the patch (as with 4.7) are the following:
>
>
> typebound_generic_15.f90:13.21:
>
>      generic :: Add => Add1, Add2  ! { dg-error "are ambiguous" }
>                       1
> Error: 'add1' and 'add2' for GENERIC 'add' at (1) are ambiguous
> typebound_generic_15.f90:11.13:
>
>      procedure :: Add1             ! { dg-error "must be a module procedure" }
>               1
> Error: 'add1' must be a module procedure or an external procedure with
> an explicit interface at (1)
> typebound_generic_15.f90:12.13:
>
>      procedure :: Add2             ! { dg-error "must be a module procedure" }
>               1
> Error: 'add2' must be a module procedure or an external procedure with
> an explicit interface at (1)
>
>
> You think there's also something wrong with the patch?
>
> Cheers,
> Janus
>
>
>
>>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.8?
>>>
>>> Cheers,
>>> Janus
>>>
>>>
>>> 2014-02-17  Janus Weil  <janus@gcc.gnu.org>
>>>
>>>       PR fortran/60231
>>>       * resolve.c (check_generic_tbp_ambiguity): Check for presence of
>>> dummy
>>>       arguments to prevent ICE.
>>>
>>>
>>> 2014-02-17  Janus Weil  <janus@gcc.gnu.org>
>>>
>>>       PR fortran/60231
>>>       * gfortran.dg/typebound_generic_15.f90: New.
>>
Janus Weil Feb. 18, 2014, 7:46 a.m. UTC | #4
2014-02-18 7:56 GMT+01:00 Tobias Burnus <burnus@net-b.de>:
>
> Am 17.02.2014 21:51, schrieb Janus Weil:
>
>> 2014-02-17 21:36 GMT+01:00 Tobias Burnus <burnus@net-b.de>:
>>>
>>> Janus Weil wrote:
>>>>
>>>> attached is a patch for an ICE-on-invalid problem with generics: We
>>>> simply don't check if any dummy args are present.
>>>
>>> There is something odd with your test case - and possibly with the patch.
>>> You state that this is an ICE-on-invalid problem; however, I do not see a
>>> dg-error in your test case.
>>
>> Oh yes, sorry. I simply forgot the dg-errors. Thanks for noticing.
>> Updated test cases attached.
>
>
> That way, it makes more sense. I have now also looked at your patch and it
> is OK. Thanks!

Thanks for the review. Committed to trunk as r207836. Will do 4.8 soon.

Cheers,
Janus



>> The errors one gets with the patch (as with 4.7) are the following:
>>
>>
>> typebound_generic_15.f90:13.21:
>>
>>      generic :: Add => Add1, Add2  ! { dg-error "are ambiguous" }
>>                       1
>> Error: 'add1' and 'add2' for GENERIC 'add' at (1) are ambiguous
>> typebound_generic_15.f90:11.13:
>>
>>      procedure :: Add1             ! { dg-error "must be a module
>> procedure" }
>>               1
>> Error: 'add1' must be a module procedure or an external procedure with
>> an explicit interface at (1)
>> typebound_generic_15.f90:12.13:
>>
>>      procedure :: Add2             ! { dg-error "must be a module
>> procedure" }
>>               1
>> Error: 'add2' must be a module procedure or an external procedure with
>> an explicit interface at (1)
>>
>>
>> You think there's also something wrong with the patch?
>>
>> Cheers,
>> Janus
>>
>>
>>
>>>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.8?
>>>>
>>>> Cheers,
>>>> Janus
>>>>
>>>>
>>>> 2014-02-17  Janus Weil  <janus@gcc.gnu.org>
>>>>
>>>>       PR fortran/60231
>>>>       * resolve.c (check_generic_tbp_ambiguity): Check for presence of
>>>> dummy
>>>>       arguments to prevent ICE.
>>>>
>>>>
>>>> 2014-02-17  Janus Weil  <janus@gcc.gnu.org>
>>>>
>>>>       PR fortran/60231
>>>>       * gfortran.dg/typebound_generic_15.f90: New.
>>>
>>>
>
diff mbox

Patch

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 207804)
+++ gcc/fortran/resolve.c	(working copy)
@@ -11362,6 +11362,7 @@  check_generic_tbp_ambiguity (gfc_tbp_generic* t1,
 {
   gfc_symbol *sym1, *sym2;
   const char *pass1, *pass2;
+  gfc_formal_arglist *dummy_args;
 
   gcc_assert (t1->specific && t2->specific);
   gcc_assert (!t1->specific->is_generic);
@@ -11384,19 +11385,33 @@  check_generic_tbp_ambiguity (gfc_tbp_generic* t1,
       return false;
     }
 
-  /* Compare the interfaces.  */
+  /* Determine PASS arguments.  */
   if (t1->specific->nopass)
     pass1 = NULL;
   else if (t1->specific->pass_arg)
     pass1 = t1->specific->pass_arg;
   else
-    pass1 = gfc_sym_get_dummy_args (t1->specific->u.specific->n.sym)->sym->name;
+    {
+      dummy_args = gfc_sym_get_dummy_args (t1->specific->u.specific->n.sym);
+      if (dummy_args)
+	pass1 = dummy_args->sym->name;
+      else
+	pass1 = NULL;
+    }
   if (t2->specific->nopass)
     pass2 = NULL;
   else if (t2->specific->pass_arg)
     pass2 = t2->specific->pass_arg;
   else
-    pass2 = gfc_sym_get_dummy_args (t2->specific->u.specific->n.sym)->sym->name;
+    {
+      dummy_args = gfc_sym_get_dummy_args (t2->specific->u.specific->n.sym);
+      if (dummy_args)
+	pass2 = dummy_args->sym->name;
+      else
+	pass2 = NULL;
+    }
+
+  /* Compare the interfaces.  */
   if (gfc_compare_interfaces (sym1, sym2, sym2->name, !t1->is_operator, 0,
 			      NULL, 0, pass1, pass2))
     {