Fix regression due to Pragma Import series

A co-worker here at AdaCore discovered that the Pragma Import series
caused a rgression.  When debugging gnat1, gdb started asking for
overload resolution like:

(gdb) call pp(n)
Multiple matches for pp
[0] cancel
[1] pp (types.union_id) at ../../gcc/gcc/ada/treepr.adb:511
[2] treepr.pp (types.union_id) at ../../gcc/gcc/ada/treepr.adb:511

This worked before the series, and is strange anyway, because the
matches refer to the same function.

This patch adds a test case for this situation and fixes the bug by
pruning identical functions in remove_extra_symbols.
This commit is contained in:
Tom Tromey 2023-04-04 09:25:21 -06:00
parent 44a37a9853
commit e9151f7d62
4 changed files with 28 additions and 0 deletions

View file

@ -5079,6 +5079,20 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
}
}
/* Two functions with the same block are identical. */
else if (syms[i].symbol->aclass () == LOC_BLOCK)
{
for (j = 0; !remove_p && j < syms.size (); j += 1)
{
if (i != j
&& syms[j].symbol->aclass () == LOC_BLOCK
&& (syms[i].symbol->value_block ()
== syms[j].symbol->value_block ()))
remove_p = true;
}
}
if (remove_p)
syms.erase (syms.begin () + i);
else