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 <fxcoud...@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