http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51788
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-07 23:15:58 UTC --- The problems is that: if ((sym->attr.use_assoc && bind_c_sym->mod_name && strcmp (bind_c_sym->mod_name, sym->module) != 0) is not true as the gsym and the sym are for the same symbol. However, one has an ambiguity: (gdb) p sym->ns->sym_root->right->right->name $44 = 0x2aaaacc36018 "one" (gdb) p sym->ns->sym_root->right->right->ambiguous $45 = 1 This ambiguity will later lead to: Error: Name 'one' at (1) is an ambiguous reference to 'one' if one tries to reference the variable. I do not see a good solution but as the ambiguity is diagnosed if one tries to reference the variable, I am tempted to use the following patch: --- a/gcc/testsuite/gfortran.dg/binding_label_tests_10_main.f03 +++ b/gcc/testsuite/gfortran.dg/binding_label_tests_10_main.f03 @@ -7 +7 @@ module binding_label_tests_10_main - integer(c_int), bind(c,name="c_one") :: one ! { dg-error "collides" } + integer(c_int), bind(c,name="c_one") :: two ! { dg-error "collides" } --- a/gcc/testsuite/gfortran.dg/binding_label_tests_11_main.f03 +++ b/gcc/testsuite/gfortran.dg/binding_label_tests_11_main.f03 @@ -8,2 +8,2 @@ contains - function one() bind(c, name="c_one") ! { dg-error "collides" } - integer(c_int) one + function two() bind(c, name="c_one") ! { dg-error "collides" } + integer(c_int) two @@ -11 +11 @@ contains - end function one + end function two