+2017-06-29 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/81247
+ * parser.c (cp_parser_namespace_definition): Immediately close the
+ namespace if there's no open-brace.
+ * name-lookup.c (do_pushdecl): Reset OLD when pushing into new
+ namespace.
+
2017-06-29 Jason Merrill <jason@redhat.com>
PR c++/81164 - ICE with invalid inherited constructor.
{
ns = current_namespace;
slot = find_namespace_slot (ns, name, true);
+ /* Update OLD to reflect the namespace we're going to be
+ pushing into. */
+ old = MAYBE_STAT_DECL (*slot);
}
old = update_binding (level, binding, slot, old, decl, is_friend);
warning (OPT_Wnamespaces, "namespace %qD entered", current_namespace);
/* Look for the `{' to validate starting the namespace. */
- cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE);
-
- /* Parse the body of the namespace. */
- cp_parser_namespace_body (parser);
+ if (cp_parser_require (parser, CPP_OPEN_BRACE, RT_OPEN_BRACE))
+ {
+ /* Parse the body of the namespace. */
+ cp_parser_namespace_body (parser);
- /* Look for the final `}'. */
- cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
+ /* Look for the final `}'. */
+ cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
+ }
if (has_visibility)
pop_visibility (1);
+2017-06-29 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/81247
+ * g++.dg/parse/pr81247-[abc].C: New.
+
2017-06-29 Carl Love <cel@us.ibm.com>
* gcc.target/powerpc/builtins-3-runnable.c (test_int_result,
--- /dev/null
+// PR c++/81247 ICE
+
+namespace N // { dg-message "previous declaration" }
+// { dg-error "expected" "" { target *-*-* } .+1 }
+template < typename T > class A
+{ // { dg-error "redeclared as different" }
+ template < T > friend class N;
+};
+
+void f ()
+{
+ A < int > a1; // { dg-message "required from here" }
+}
--- /dev/null
+// PR c++/81247 confused error
+
+namespace N { // { dg-message "previous declaration" }
+}
+
+template < typename T > class A
+{ // { dg-error "redeclared as different" }
+ template < T > friend class N;
+};
+
+void f ()
+{
+ A < int > a1;
+}
--- /dev/null
+// PR c++/81247 confused error
+
+namespace N { // { dg-message "previous declaration" }
+ template < typename T > class A
+ { // { dg-error "conflicts with a previous" }
+ template < T > friend class N;
+ };
+}
+
+void f ()
+{
+ N::A < int > a1;
+}