+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>
PR c++/69855
}
/* 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)
{
tree d = NULL_TREE;
TREE_PUBLIC (d) = 0;
else
TREE_PUBLIC (d) = 1;
- pushdecl (d);
+ if (pushdecl (d) == error_mark_node)
+ {
+ timevar_cond_stop (TV_NAME_LOOKUP, subtime);
+ return false;
+ }
if (anon)
{
/* Clear DECL_NAME for the benefit of debugging back ends. */
current_namespace = d;
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
+ return true;
}
/* Pop from the scope of the current namespace. */
extern void pop_inner_scope (tree, tree);
extern void push_binding_level (cp_binding_level *);
\f
-extern void push_namespace (tree);
+extern bool push_namespace (tree);
extern void pop_namespace (void);
extern void push_nested_namespace (tree);
extern void pop_nested_namespace (tree);
}
/* Start the namespace. */
- push_namespace (identifier);
+ bool ok = push_namespace (identifier);
/* Parse any nested namespace definition. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SCOPE))
/* "inline namespace" is equivalent to a stub namespace definition
followed by a strong using directive. */
- if (is_inline)
+ if (is_inline && ok)
{
tree name_space = current_namespace;
/* Set up namespace association. */
pop_namespace ();
/* Finish the namespace. */
- pop_namespace ();
+ if (ok)
+ pop_namespace ();
/* Look for the final `}'. */
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>
* gcc.dg/tree-ssa/pr21417.c: Update expected output.
--- /dev/null
+// PR c++/60385
+
+float foo4(); // { dg-message "previous declaration" }
+
+namespace foo4 // { dg-error "redeclared" }
+{
+ struct bar6
+ {
+ friend wchar_t bar1();
+ };
+}