Hi,
this regression is caused by my fix for c++/60385, where I changed
push_namespace to early return (a bool) when pushdecl fails. In the
present testcase, a different push_namespace call in
cp_parser_namespace_definition, for nested namespace definitions, fails,
thus returns early, and that is inconsistent with the final loop
(pop_namespace ICEs):
/* Finish the nested namespace definitions. */
while (nested_definition_count--)
pop_namespace ();
To fix this problem, I think we can simply increment
nested_definition_count only when push_namespace succeeds. Tested
x86_64-linux.
Thanks, Paolo.
//////////////////////
/cp
2016-12-02 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/78637
* parser.c (cp_parser_namespace_definition): Increment
nested_definition_count only if push_namespace succeeds.
/testsuite
2016-12-02 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/78637
* g++.dg/parse/namespace14.C: New.
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 243171)
+++ cp/parser.c (working copy)
@@ -18184,8 +18184,8 @@ cp_parser_namespace_definition (cp_parser* parser)
cp_parser_error (parser, "nested identifier required");
break;
}
- ++nested_definition_count;
- push_namespace (identifier);
+ if (push_namespace (identifier))
+ ++nested_definition_count;
}
}
Index: testsuite/g++.dg/parse/namespace14.C
===================================================================
--- testsuite/g++.dg/parse/namespace14.C (revision 0)
+++ testsuite/g++.dg/parse/namespace14.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/78637
+
+namespace X {
+class Y;
+}
+namespace X::Y z; // { dg-error "namespace|expected|type" }