Found when trying to create a patch for PR 51578. Seemingly, the generated tree is now slightly different. The problem is that the test case gfortran.dg/binding_label_tests_10_main.f03 fails with my patch - without, one gets the following. However, if one swaps the lines use binding_label_tests_10_main use binding_label_tests_10 ! { dg-error "collides" } I get now an error with my patch - but none with the unpatched GCC. Hence, the test case is not stable. At least with my patch it fails in resolve.c's gfc_verify_binding_labels as: if (sym->attr.if_source == IFSRC_DECL is not fulfilled. The reason is that symbols loaded from .mod files are have IFSRC_UNKNOWN. A "proper" error message looks as follows: gfortran.dg/binding_label_tests_10_main.f03:11.6: use binding_label_tests_10 ! { dg-error "collides" } 1 gfortran.dg/binding_label_tests_10_main.f03:7.45: integer(c_int), bind(c,name="c_one") :: one ! { dg-error "collides" } 2 Error: Binding label 'c_one' at (1) collides with global entity 'c_one' at (2) (Cf. PR 48858 comment 9 for some information about binding labels.)
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
I confirm that if the lines use binding_label_tests_10 ! { dg-error "Variable one ..." } use binding_label_tests_10_main are swapped, the code is compiled without error at r206072. I am not sure to understand the remaining of this PR.
Is this still a problem?
> Is this still a problem? No feedback, closing as INVALID.