* [PATCH gfortran] PR 61450: ICE in gfc_global_used()
@ 2017-09-24 14:13 Dominique d'Humières
2017-09-30 12:21 ` [PATCH gfortran v2] " Dominique d'Humières
0 siblings, 1 reply; 4+ messages in thread
From: Dominique d'Humières @ 2017-09-24 14:13 UTC (permalink / raw)
To: FX; +Cc: Thomas Koenig, gfortran, gcc-patches
Rebased FX’s patch.
Tested on x86_64-apple-darwin16.Is it OK with the proper log entries added?
TIA
Dominique
diff -up ../_clean/gcc/fortran/parse.c gcc/fortran/parse.c
--- ../_clean/gcc/fortran/parse.c 2017-01-22 20:50:56.000000000 +0100
+++ gcc/fortran/parse.c 2017-01-24 10:01:32.000000000 +0100
@@ -5724,34 +5724,33 @@ gfc_global_used (gfc_gsymbol *sym, locus
switch(sym->type)
{
case GSYM_PROGRAM:
- name = "PROGRAM";
+ name = "as a PROGRAM ";
break;
case GSYM_FUNCTION:
- name = "FUNCTION";
+ name = "as a FUNCTION ";
break;
case GSYM_SUBROUTINE:
- name = "SUBROUTINE";
+ name = "as a SUBROUTINE ";
break;
case GSYM_COMMON:
- name = "COMMON";
+ name = "as a COMMON ";
break;
case GSYM_BLOCK_DATA:
- name = "BLOCK DATA";
+ name = "as a BLOCK DATA ";
break;
case GSYM_MODULE:
- name = "MODULE";
+ name = "as a MODULE ";
break;
default:
- gfc_internal_error ("gfc_global_used(): Bad type");
- name = NULL;
+ name = "";
}
if (sym->binding_label)
- gfc_error ("Global binding name %qs at %L is already being used as a %s "
+ gfc_error ("Global binding name %qs at %L is already being used %s"
"at %L", sym->binding_label, where, name, &sym->where);
else
- gfc_error ("Global name %qs at %L is already being used as a %s at %L",
- sym->name, where, name, &sym->where);
+ gfc_error ("Global name %qs at %L is already being used %s"
+ "at %L", sym->name, where, name, &sym->where);
}
--- ../_clean/gcc/testsuite/gfortran.dg/binding_label_tests_28.f90 1970-01-01 01:00:00.000000000 +0100
+++ gcc/testsuite/gfortran.dg/binding_label_tests_28.f90 2017-01-13 17:32:01.000000000 +0100
@@ -0,0 +1,12 @@
+! { dg-do compile }
+!
+! PR fortran/61450
+! Contributed by Francois-Xavier Coudert <fxcoudert@gmail.com>
+!
+module p
+ integer i1 ! { dg-error "Global binding name 'foo' at .1. is already being used at .2." }
+ bind(c,name="foo") :: i1
+end module
+
+subroutine truc() bind(c,name="foo") ! { dg-error "Global binding name 'foo' at .1. is already being used at .2." }
+end
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH gfortran v2] PR 61450: ICE in gfc_global_used()
2017-09-24 14:13 [PATCH gfortran] PR 61450: ICE in gfc_global_used() Dominique d'Humières
@ 2017-09-30 12:21 ` Dominique d'Humières
2017-10-01 8:38 ` Thomas Koenig
0 siblings, 1 reply; 4+ messages in thread
From: Dominique d'Humières @ 2017-09-30 12:21 UTC (permalink / raw)
To: FX; +Cc: Thomas Koenig, gfortran, gcc-patches
As noticed by Thomas on IRC, the FX's patch may not be translator friendly. I have now tested the following
--- ../_clean/gcc/fortran/parse.c 2017-09-01 19:00:10.000000000 +0200
+++ gcc/fortran/parse.c 2017-09-28 17:55:14.000000000 +0200
@@ -5742,16 +5742,28 @@ gfc_global_used (gfc_gsymbol *sym, locus
name = "MODULE";
break;
default:
- gfc_internal_error ("gfc_global_used(): Bad type");
name = NULL;
}
- if (sym->binding_label)
- gfc_error ("Global binding name %qs at %L is already being used as a %s "
- "at %L", sym->binding_label, where, name, &sym->where);
+ if (name)
+ {
+ if (sym->binding_label)
+ gfc_error ("Global binding name %qs at %L is already being used "
+ "as a %s at %L", sym->binding_label, where, name,
+ &sym->where);
+ else
+ gfc_error ("Global name %qs at %L is already being used as "
+ "a %s at %L", sym->name, where, name, &sym->where);
+ }
else
- gfc_error ("Global name %qs at %L is already being used as a %s at %L",
- sym->name, where, name, &sym->where);
+ {
+ if (sym->binding_label)
+ gfc_error ("Global binding name %qs at %L is already being used "
+ "at %L", sym->binding_label, where, &sym->where);
+ else
+ gfc_error ("Global name %qs at %L is already being used at %L",
+ sym->name, where, &sym->where);
+ }
}
I have also tried to avoid the nested IFs following the Thomas’ suggestion to use
label = sym->binding_label ? sym->binding_label : sym->name;
but this does not handle "Global binding name "/"Global name ».
Dominique
> Le 24 sept. 2017 à 16:13, Dominique d'Humières <dominiq@lps.ens.fr> a écrit :
>
> Rebased FX’s patch.
>
> Tested on x86_64-apple-darwin16.Is it OK with the proper log entries added?
>
> TIA
>
> Dominique
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH gfortran v2] PR 61450: ICE in gfc_global_used()
2017-09-30 12:21 ` [PATCH gfortran v2] " Dominique d'Humières
@ 2017-10-01 8:38 ` Thomas Koenig
2017-10-01 10:03 ` Dominique d'Humières
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Koenig @ 2017-10-01 8:38 UTC (permalink / raw)
To: Dominique d'Humières, FX; +Cc: gfortran, gcc-patches
Hi Dominique,
The patch is OK for trunk.
Thanks!
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH gfortran v2] PR 61450: ICE in gfc_global_used()
2017-10-01 8:38 ` Thomas Koenig
@ 2017-10-01 10:03 ` Dominique d'Humières
0 siblings, 0 replies; 4+ messages in thread
From: Dominique d'Humières @ 2017-10-01 10:03 UTC (permalink / raw)
To: Thomas Koenig; +Cc: FX, gfortran, gcc-patches
Committed as revision r253328 with the change logs
2017-10-01 Dominique d'Humieres <dominiq@lps.ens.fr>
PR fortran/61450
* parse.c (gfc_global_used): Replace the gfc_internal_error
with an error.
2017-10-01 Dominique d'Humieres <dominiq@lps.ens.fr>
PR fortran/61450
* gfortran.dg/binding_label_tests_28.f90: New test.
Thanks for the review,
Dominique
> Le 1 oct. 2017 à 10:37, Thomas Koenig <tkoenig@netcologne.de> a écrit :
>
> Hi Dominique,
>
> The patch is OK for trunk.
>
> Thanks!
>
> Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-10-01 10:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-24 14:13 [PATCH gfortran] PR 61450: ICE in gfc_global_used() Dominique d'Humières
2017-09-30 12:21 ` [PATCH gfortran v2] " Dominique d'Humières
2017-10-01 8:38 ` Thomas Koenig
2017-10-01 10:03 ` Dominique d'Humières
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).