Consider the following testcase:
template<typename T> struct A
{
template<T&> struct B;
};
A<void> a;
When instantiating A<void> the compiler has to substitute T with
void in the declaration of struct B. This is done in tsubst_decl by
calling tsubst_template_args. Since void& is an invalid type, the
substitution fails and tsubst_template_args correctly returns
error_mark_node.
However, the compiler fails to check for the error_mark_node and instead
calls retrieve_specialization with an error_mark_node as second argument.
This results in an ICE.
The attached patch fixes the ICE by adding a check for error_mark_node
and adds the above testcase.
Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for mainline?