[RFA] Fix c++/16253 (tag/variable name collision)
Commit Message
On 03/24/2014 07:15 AM, Joel Brobecker wrote:
> This may not be directly related to your patch. I seem to have seen
> some unexplainable behavior in GDB occasionally in the recent past
> making me wonder whether there might be something fishy in the symbol
> lookup for Ada.
It is my patch that is causing the problems.
In this case, add_nonlocal_symbols is calling the qf
map_matching_symbols method which is calling match_partial_symbol. Since
this method now does strict matches against domain, an explicit check
for STRUCT_DOMAIN matches must be added.
Give this amendment a shot and see how it goes. I suspect there are
probably one or two more places where this occurs. [The easiest thing to
do is audit any function which uses "VAR_DOMAIN".]
Keith
Comments
> In this case, add_nonlocal_symbols is calling the qf
> map_matching_symbols method which is calling match_partial_symbol.
> Since this method now does strict matches against domain, an
> explicit check for STRUCT_DOMAIN matches must be added.
>
> Give this amendment a shot and see how it goes. I suspect there are
> probably one or two more places where this occurs. [The easiest
> thing to do is audit any function which uses "VAR_DOMAIN".]
I was thinking of the very same patch :), and it tested fine.
Can you remove the curly braces in the second call? They should
be unnecessary in this case, and our CS asks us to avoid them
in that situation (the only exception is when the body also
contains a comment).
Thanks!
> + {
> + objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
> + aux_add_nonlocal_symbols,
> + &data, wild_match, NULL);
> + if (domain == VAR_DOMAIN)
> + {
> + objfile->sf->qf->map_matching_symbols (objfile, name,
> + STRUCT_DOMAIN, global,
> + aux_add_nonlocal_symbols,
> + &data, wild_match, NULL);
> + }
> + }
> else
> - objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
> - aux_add_nonlocal_symbols, &data,
> - full_match, compare_names);
> + {
> + objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
> + aux_add_nonlocal_symbols,
> + &data, full_match,
> + compare_names);
> + if (domain == VAR_DOMAIN)
> + {
> + objfile->sf->qf->map_matching_symbols (objfile, name,
> + STRUCT_DOMAIN, global,
> + aux_add_nonlocal_symbols,
> + &data, full_match,
> + compare_names);
> + }
> + }
> }
>
> if (num_defns_collected (obstackp) == 0 && global && !is_wild_match)
@@ -5336,13 +5336,33 @@ add_nonlocal_symbols (struct obstack *obstackp, const char *name,
data.objfile = objfile;
if (is_wild_match)
- objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
- aux_add_nonlocal_symbols, &data,
- wild_match, NULL);
+ {
+ objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
+ aux_add_nonlocal_symbols,
+ &data, wild_match, NULL);
+ if (domain == VAR_DOMAIN)
+ {
+ objfile->sf->qf->map_matching_symbols (objfile, name,
+ STRUCT_DOMAIN, global,
+ aux_add_nonlocal_symbols,
+ &data, wild_match, NULL);
+ }
+ }
else
- objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
- aux_add_nonlocal_symbols, &data,
- full_match, compare_names);
+ {
+ objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
+ aux_add_nonlocal_symbols,
+ &data, full_match,
+ compare_names);
+ if (domain == VAR_DOMAIN)
+ {
+ objfile->sf->qf->map_matching_symbols (objfile, name,
+ STRUCT_DOMAIN, global,
+ aux_add_nonlocal_symbols,
+ &data, full_match,
+ compare_names);
+ }
+ }
}
if (num_defns_collected (obstackp) == 0 && global && !is_wild_match)