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] | |
Hi,
we have these long standing issues with code like (c++/60385):
float foo4();
namespace foo4
{
// ....
}
where the name of the namespace conflicts with an existing declaration.
Error recovery is currently suboptimal, for example, c++/60385 is about
struct bar6
{
friend wchar_t bar1();
};
inside the namespace: due to the code in do_friend:
push_nested_namespace (ns);
decl = pushdecl_namespace_level (decl, /*is_friend=*/true);
pop_nested_namespace (ns);
we issue duplicate diagnostic about the wrong name and later we crash in
pop_namespace (the second time in push_namespace,
IDENTIFIER_NAMESPACE_VALUE isn't found set for the malformed namespace,
thus need_new is true, pushdecl is called...)
Now, I'm wondering how far we want to go with error recovery for such snippets. Certainly, in analogy with the code at the beginning of cp_parser_class_specifier_1, we can completely skip the body of such malformed namespaces. That would be the first attached patchlet. Or we can go on in cp_parser_namespace_definition but remember that push_namespace didn't really succeed and keep things consistent, thus avoid crashing in pop_namespace later, as currently happens. That would be second patchlet. Both ideas pass testing and work for c++/68723 too (as expected, the first patchlet leads to particularly neat diagnostic for the very broken snippet in c++/68723, only the error about the wrong namespace name, as for c++/60385).
Thanks! Paolo. //////////////////////
Attachment:
patch_60385_draft
Description: Text document
Attachment:
patch_60385_draft2
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |