This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] fix PR c++/14136: Duplicate error message (take two)


On 15 Dec, Mark Mitchell wrote:
> Volker Reichelt wrote:
>> 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.
> 
> Doesn't it make more sense to avoid cp_parser-diagnose_invalid_type_name 
> in a tentative parse?  If not, it probably makes sense to commit to the 
> tentative parse at that point.  The c_p_d_i_t function is only used to 
> issue diagnostics, it seems like nothing more than a waste of time to be 
> using it during tentative parsing.

We are not calling c_p_d_i_t inside a tentative parse. Instead c_p_d_i_t
starts a tentative parse to see whether two identifiers follow or not.
If not (i.e. no error is detected), the tentative parse is aborted.

Regards,
Volker



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]