Commit be3b7dcf by Nathan Sidwell Committed by Nathan Sidwell

re PR c++/81247 (ICE on invalid C++ code with malformed namespace declaration:…

re PR c++/81247 (ICE on invalid C++ code with malformed namespace declaration: in do_push_nested_namespace, at cp/name-lookup.c:6002)

	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.

From-SVN: r249804
parent 6044f5e3
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.
......
......@@ -2422,6 +2422,9 @@ do_pushdecl (tree decl, bool is_friend)
{
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);
......
......@@ -18397,13 +18397,14 @@ cp_parser_namespace_definition (cp_parser* parser)
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,
......
// 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" }
}
// 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;
}
// 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment