Ok, here's take two.
For the following code snippet we issue a duplicate diagnostic on mainline:
==========================
struct A
{
typedef A B;
~B();
};
==========================
PR14136.cc:4: error: typedef-name 'A::B' used as destructor declarator
PR14136.cc:4: error: typedef-name 'A::B' used as destructor declarator
This is because in cp_parser_member_declaration we first call
cp_parser_parse_and_diagnose_invalid_type_name. This eventually ends
up in calls cp_parser_unqualified_id which issues the first error message.
(Btw, the duplicate error message first appeared when
cp_parser_parse_and_diagnose_invalid_type_name was introduced.)
Later in cp_parser_member_declaration we call cp_parser_declarator.
This again ends up in cp_parser_unqualified_id so that the second
error message is issued.
The following patch suppresses the first error message which was
issued in an uncommitted tentative parse.