Commit 8008c4d2 by Paolo Carlini Committed by Paolo Carlini

re PR c++/60385 (confused by earlier errors, bailing out)

/cp
2016-05-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60385
	* name-lookup.c (push_namespace): Return bool, false when pushdecl
	fails.
	* name-lookup.h (push_namespace): Adjust declaration.
	* parser.c (cp_parser_namespace_definition): Check push_namespace
	return value.

/testsuite
2016-05-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60385
	* g++.dg/parse/namespace13.C: New.

From-SVN: r236835
parent 9a01befb
2016-05-27 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60385
* name-lookup.c (push_namespace): Return bool, false when pushdecl
fails.
* name-lookup.h (push_namespace): Adjust declaration.
* parser.c (cp_parser_namespace_definition): Check push_namespace
return value.
2016-05-27 Ville Voutilainen <ville.voutilainen@gmail.com> 2016-05-27 Ville Voutilainen <ville.voutilainen@gmail.com>
PR c++/69855 PR c++/69855
......
...@@ -3701,9 +3701,10 @@ handle_namespace_attrs (tree ns, tree attributes) ...@@ -3701,9 +3701,10 @@ handle_namespace_attrs (tree ns, tree attributes)
} }
/* Push into the scope of the NAME namespace. If NAME is NULL_TREE, then we /* Push into the scope of the NAME namespace. If NAME is NULL_TREE, then we
select a name that is unique to this compilation unit. */ select a name that is unique to this compilation unit. Returns FALSE if
pushdecl fails, TRUE otherwise. */
void bool
push_namespace (tree name) push_namespace (tree name)
{ {
tree d = NULL_TREE; tree d = NULL_TREE;
...@@ -3777,7 +3778,11 @@ push_namespace (tree name) ...@@ -3777,7 +3778,11 @@ push_namespace (tree name)
TREE_PUBLIC (d) = 0; TREE_PUBLIC (d) = 0;
else else
TREE_PUBLIC (d) = 1; TREE_PUBLIC (d) = 1;
pushdecl (d); if (pushdecl (d) == error_mark_node)
{
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return false;
}
if (anon) if (anon)
{ {
/* Clear DECL_NAME for the benefit of debugging back ends. */ /* Clear DECL_NAME for the benefit of debugging back ends. */
...@@ -3795,6 +3800,7 @@ push_namespace (tree name) ...@@ -3795,6 +3800,7 @@ push_namespace (tree name)
current_namespace = d; current_namespace = d;
timevar_cond_stop (TV_NAME_LOOKUP, subtime); timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return true;
} }
/* Pop from the scope of the current namespace. */ /* Pop from the scope of the current namespace. */
......
...@@ -312,7 +312,7 @@ extern tree push_inner_scope (tree); ...@@ -312,7 +312,7 @@ extern tree push_inner_scope (tree);
extern void pop_inner_scope (tree, tree); extern void pop_inner_scope (tree, tree);
extern void push_binding_level (cp_binding_level *); extern void push_binding_level (cp_binding_level *);
extern void push_namespace (tree); extern bool push_namespace (tree);
extern void pop_namespace (void); extern void pop_namespace (void);
extern void push_nested_namespace (tree); extern void push_nested_namespace (tree);
extern void pop_nested_namespace (tree); extern void pop_nested_namespace (tree);
......
...@@ -17549,7 +17549,7 @@ cp_parser_namespace_definition (cp_parser* parser) ...@@ -17549,7 +17549,7 @@ cp_parser_namespace_definition (cp_parser* parser)
} }
/* Start the namespace. */ /* Start the namespace. */
push_namespace (identifier); bool ok = push_namespace (identifier);
/* Parse any nested namespace definition. */ /* Parse any nested namespace definition. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SCOPE)) if (cp_lexer_next_token_is (parser->lexer, CPP_SCOPE))
...@@ -17582,7 +17582,7 @@ cp_parser_namespace_definition (cp_parser* parser) ...@@ -17582,7 +17582,7 @@ cp_parser_namespace_definition (cp_parser* parser)
/* "inline namespace" is equivalent to a stub namespace definition /* "inline namespace" is equivalent to a stub namespace definition
followed by a strong using directive. */ followed by a strong using directive. */
if (is_inline) if (is_inline && ok)
{ {
tree name_space = current_namespace; tree name_space = current_namespace;
/* Set up namespace association. */ /* Set up namespace association. */
...@@ -17610,7 +17610,8 @@ cp_parser_namespace_definition (cp_parser* parser) ...@@ -17610,7 +17610,8 @@ cp_parser_namespace_definition (cp_parser* parser)
pop_namespace (); pop_namespace ();
/* Finish the namespace. */ /* Finish the namespace. */
pop_namespace (); if (ok)
pop_namespace ();
/* Look for the final `}'. */ /* Look for the final `}'. */
cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE); cp_parser_require (parser, CPP_CLOSE_BRACE, RT_CLOSE_BRACE);
} }
2016-05-27 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60385
* g++.dg/parse/namespace13.C: New.
2016-05-26 Jeff Law <law@redhat.com> 2016-05-26 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/pr21417.c: Update expected output. * gcc.dg/tree-ssa/pr21417.c: Update expected output.
......
// PR c++/60385
float foo4(); // { dg-message "previous declaration" }
namespace foo4 // { dg-error "redeclared" }
{
struct bar6
{
friend wchar_t bar1();
};
}
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