7- I needed to hack the C++ mangler to avoid ICEs when dealing
with symbols that are mangled by free_lang_data.
a- In decl_is_template_id, we call PRIMARY_TEMPLATE_P on the
result of DECL_TI_TEMPLATE. The problem here is that
DECL_TI_TEMPLATE can return 3 kinds of nodes:
FUNCTION_DECL, OVERLOAD or IDENTIFIER_NODE. But
PRIMARY_TEMPLATE_P can only handle FUNCTION_DECL.
In very many cases, we are getting OVERLOAD and
IDENTIFIER_NODEs, causing an ICE at the call. This is the
hunk that Jason and Mark had objected to in my
free_lang_data merge. I could avoid this in trunk because
we don't enable free_lang_data if -g is on. However, in
the branch, this is always enabled.
I do not know enough to figure out a real solution to this,
so I will appreciate any hints on what to do here. I
realize that this means that we are mangling many more
symbols that we should. So, part of this will be try to
make need_assembler_name_p smarter. However, I think that
we cannot escape this easily. For LTO to be able to merge
decls, we will need to mangle more than before (maybe I'm
wrong about this).
b- In write_template_arg, we implicitly assume that
CONST_DECLs will hold a tcc_constant in their DECL_INITIAL.
However, as is the case in
testsuite/g++.dg/ext/tmplattr9.C, we can have another
CONST_DECL which in turn may have no DECL_INITIAL at all:
template<int> struct B
{
enum { a, b = a };
void bar(B<b>) __attribute((weak));
};
When mangling B::bar, we ICE trying to mangle 'b'. I
worked around the issue by mangling 'b' as a DECL, but
that that produces an unmangleable string, so this is
obviously wrong. Any hints?