[fortran] PR39239 EQUIVALENCE and BIND(C)

Message ID a1f779fc-0e8a-70be-5e2f-f05d47f5b2bc@student.ethz.ch
State New
Headers show

Commit Message

Nicolas Koenig March 19, 2017, 12:15 a.m.
Hello everyone,

I submitted this patch a week ago, but I think it got lost. It adds an 
error if BIND(C) is used with EQUIVALENCE.

Nicolas

Regression tested for x86_64-pc-linux-gnu.

2017-03-18  Nicolas Koenig  <koenigni@student.ethz.ch>

                 PR fortran/39239
                 * resolve.c (resolve_equivalence): report an error if 
an equivalence variable is BIND(C).

2017-03-18  Nicolas Koenig  <koenigni@student.ethz.ch>

                 PR fortran/39239
                 * gfortran.dg/equiv_constraint_bind_c.f90: New test.

Comments

Paul Richard Thomas March 19, 2017, 12:02 p.m. | #1
Hi Nicolas,

Is there some reason that you didn't use symbol.c(check_conflict)? The
conflict check could be added at line 547. If this results in
repetitions of the error message, then your patch is OK. Otherwise, I
would pop it in there.

Do you have commit rights? ie. have you done the FSF paperwork?

Welcome aboard!

Paul

On 19 March 2017 at 00:15, Nicolas Koenig <koenigni@student.ethz.ch> wrote:
> Hello everyone,
>
> I submitted this patch a week ago, but I think it got lost. It adds an error
> if BIND(C) is used with EQUIVALENCE.
>
> Nicolas
>
> Regression tested for x86_64-pc-linux-gnu.
>
> 2017-03-18  Nicolas Koenig  <koenigni@student.ethz.ch>
>
>                 PR fortran/39239
>                 * resolve.c (resolve_equivalence): report an error if an
> equivalence variable is BIND(C).
>
> 2017-03-18  Nicolas Koenig  <koenigni@student.ethz.ch>
>
>                 PR fortran/39239
>                 * gfortran.dg/equiv_constraint_bind_c.f90: New test.
>
Paul Richard Thomas March 20, 2017, 9:35 a.m. | #2
Dear Nicolas,

This is OK for trunk.

Thanks for the patch.

Paul

On 19 March 2017 at 14:34, Nicolas Koenig <koenigni@student.ethz.ch> wrote:
> Hello Paul,
>
> there isn't really a reason for that except for not knowing where to put the
> error. Attached are the new patch & test case.
>
> The paperwork is done and I have commit rights.
>
> Thanks for the kind welcome!
>
> Nicolas
>
> Regression tested for x86_64-pc-linux-gnu.
>
> 2017-03-12 Nicolas Koenig <koenigni@student.ethz.ch>
>
>     PR fortran/39239
>     * symbol.c (check_conflict): report an error if an EQUIVALENCE variable
> is BIND(C).
>
> 2017-03-12 Nicolas Koenig <koenigni@student.ethz.ch>
>
>     PR fortran/39239
>     * gfortran.dg/equiv_constraint_bind_c.f90: New test.
>
>
> On 03/19/2017 01:02 PM, Paul Richard Thomas wrote:
>>
>> Hi Nicolas,
>>
>> Is there some reason that you didn't use symbol.c(check_conflict)? The
>> conflict check could be added at line 547. If this results in
>> repetitions of the error message, then your patch is OK. Otherwise, I
>> would pop it in there.
>>
>> Do you have commit rights? ie. have you done the FSF paperwork?
>>
>> Welcome aboard!
>>
>> Paul
>>
>> On 19 March 2017 at 00:15, Nicolas Koenig <koenigni@student.ethz.ch>
>> wrote:
>>>
>>> Hello everyone,
>>>
>>> I submitted this patch a week ago, but I think it got lost. It adds an
>>> error
>>> if BIND(C) is used with EQUIVALENCE.
>>>
>>> Nicolas
>>>
>>> Regression tested for x86_64-pc-linux-gnu.
>>>
>>> 2017-03-18  Nicolas Koenig  <koenigni@student.ethz.ch>
>>>
>>>                  PR fortran/39239
>>>                  * resolve.c (resolve_equivalence): report an error if an
>>> equivalence variable is BIND(C).
>>>
>>> 2017-03-18  Nicolas Koenig  <koenigni@student.ethz.ch>
>>>
>>>                  PR fortran/39239
>>>                  * gfortran.dg/equiv_constraint_bind_c.f90: New test.
>>>
>>
>>
>

Patch

Index: resolve.c
===================================================================
--- resolve.c	(revision 246070)
+++ resolve.c	(working copy)
@@ -15675,6 +15675,13 @@  resolve_equivalence (gfc_equiv *eq)
 	  && !resolve_equivalence_derived (e->ts.u.derived, sym, e))
 	continue;
 
+      if (sym->attr.is_bind_c)
+	{
+      	  gfc_error ("EQUIVALENCE object %qs at %L cannot be BIND(C)",
+                     sym->name, &e->where);
+	  continue;
+	}
+
       /* Check that the types correspond correctly:
 	 Note 5.28:
 	 A numeric sequence structure may be equivalenced to another sequence