[patch] fix PR c++/14136: Duplicate error message (take two)
Volker Reichelt
reichelt@igpm.rwth-aachen.de
Wed Dec 15 17:41:00 GMT 2004
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.
The patch comes without testcase since nobody seems to know how to
force the testsuite to check for duplicate error messages :-(
Bootstrapped and regtested.
OK to apply to mainline?
Regards,
Volker
2004-12-15 Volker Reichelt <reichelt@igpm.rwth-aaachen.de>
PR c++/14136
* parser.c (cp_parser_unqualified_id): Do not issue error message
for typedef-name as destructor declarator when performing an
uncommitted tentative parse.
===================================================================
diff -u -p -r1.276 parser.c
--- gcc/gcc/cp/parser.c 3 Nov 2004 02:48:37 -0000 1.276
+++ gcc/gcc/cp/parser.c 27 Nov 2004 07:07:14 -0000
@@ -3234,7 +3234,8 @@ cp_parser_unqualified_id (cp_parser* par
identifier in the declarator for a destructor declaration. */
if (declarator_p
&& !DECL_IMPLICIT_TYPEDEF_P (type_decl)
- && !DECL_SELF_REFERENCE_P (type_decl))
+ && !DECL_SELF_REFERENCE_P (type_decl)
+ && !cp_parser_uncommitted_to_tentative_parse_p (parser))
error ("typedef-name %qD used as destructor declarator",
type_decl);
===================================================================
More information about the Gcc-patches
mailing list