Commit 5714705f by Paolo Carlini Committed by Paolo Carlini

re PR c++/26155 (ICE after error with namespace alias)

/cp
2012-06-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/26155
	* name-lookup.c (push_namespace): When error recovery is
	impossible just error out in duplicate_decls.

/testsuite
2012-06-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/26155
	* g++.dg/parse/namespace-alias-1.C: New.

From-SVN: r188113
parent 874a3589
2012-06-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/26155
* name-lookup.c (push_namespace): When error recovery is
impossible just error out in duplicate_decls.
2012-05-31 Steven Bosscher <steven@gcc.gnu.org>
* call.c: Do not include output.h.
......
......@@ -3518,8 +3518,8 @@ void
push_namespace (tree name)
{
tree d = NULL_TREE;
int need_new = 1;
int implicit_use = 0;
bool need_new = true;
bool implicit_use = false;
bool anon = !name;
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
......@@ -3535,8 +3535,8 @@ push_namespace (tree name)
d = IDENTIFIER_NAMESPACE_VALUE (name);
if (d)
/* Reopening anonymous namespace. */
need_new = 0;
implicit_use = 1;
need_new = false;
implicit_use = true;
}
else
{
......@@ -3544,13 +3544,36 @@ push_namespace (tree name)
d = IDENTIFIER_NAMESPACE_VALUE (name);
if (d != NULL_TREE && TREE_CODE (d) == NAMESPACE_DECL)
{
need_new = 0;
if (DECL_NAMESPACE_ALIAS (d))
{
error ("namespace alias %qD not allowed here, assuming %qD",
d, DECL_NAMESPACE_ALIAS (d));
d = DECL_NAMESPACE_ALIAS (d);
tree dna = DECL_NAMESPACE_ALIAS (d);
if (dna)
{
/* We do some error recovery for, eg, the redeclaration
of M here:
namespace N {}
namespace M = N;
namespace M {}
However, in nasty cases like:
namespace N
{
namespace M = N;
namespace M {}
}
we just error out below, in duplicate_decls. */
if (NAMESPACE_LEVEL (dna)->level_chain
== current_binding_level)
{
error ("namespace alias %qD not allowed here, "
"assuming %qD", d, dna);
d = dna;
need_new = false;
}
}
else
need_new = false;
}
}
......
2012-06-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/26155
* g++.dg/parse/namespace-alias-1.C: New.
2012-06-01 Christian Bruel <christian.bruel@st.com>
* gcc.dg/spec-options.c: New test.
......
// PR c++/26155
namespace N
{
namespace M = N; // { dg-error "previous declaration" }
namespace M {} // { dg-error "declaration of namespace" }
}
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