As Richard pointed out, I used wrong wording, so let me give long
explanation, just to be understood correctly.
The most common kind of error is typos. The next is something omitted,
these errors are typical for experienced programmers ("brain is faster than
fingers"). Misplaced and extra things are much rarer, the latter are more
often for novices. So if we have wrong piece of code, we should try to
recover assuming that something is missed. The original case:
template struct pr15466a { int a; };
can be recovered by:
- Adding parameter list to 'template', making it a template definition, or
- Removal of 'template' turning it into non-template class definition.
According the above rules, missed things are more probable, than spurious
'template'. People are lazy, if a user typed 'template', there must a
template somewhere. So this code should be recovered as template definition.
Now let's consider the next example:
template <class T> struct pr15466a;
template struct pr15466a { int a; };
In this case we know that 'pr15466a' is a template, so almost definitely
the second line must be recovered as a specialization by putting '<>' after
'template' and
template parameters after 'pr15466'.
Not to be too picky, but I think you meant "template arguments" here? 
Chances that a user made two different errors (typed extra 'template' and
made a typo in 'pr15466') are pretty low.
Bottom line: in both cases I would complain about missed template
arguments.
I believe there have been long and substantial discussions before this bug
fix about the proper way to recover from errors. This fix does not address
what is the proper way, but rather applies what seems to be the currently
agreed-upon rules. Therefore, I'd say that the issue you raise here is
orthogonal to this bug fix.
Another problem with your fix is too long messages. Short messages (no
more that 5-6 significant words) are perceived as a whole, longer require
reading which is substantially (several times) slower and annoy users. The
message
class cannot be defined in an explicit instantiation; if this
declaration is meant to be a class definition, remove the 'template' keyword
I would make something like:
class cannot be defined in an explicit instantiation; spurious
'template'?
You may be right, but this bug fix did not make this message. So, I'd
suggest filing a separate bug report addressing the length of error
messages.
I hope this helps.
Thanks,
-- Larisse.