mirror of git://gcc.gnu.org/git/gcc.git
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
This commit is contained in:
parent
874a358949
commit
5714705f11
|
@ -1,3 +1,9 @@
|
||||||
|
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>
|
2012-05-31 Steven Bosscher <steven@gcc.gnu.org>
|
||||||
|
|
||||||
* call.c: Do not include output.h.
|
* call.c: Do not include output.h.
|
||||||
|
|
|
@ -3518,8 +3518,8 @@ void
|
||||||
push_namespace (tree name)
|
push_namespace (tree name)
|
||||||
{
|
{
|
||||||
tree d = NULL_TREE;
|
tree d = NULL_TREE;
|
||||||
int need_new = 1;
|
bool need_new = true;
|
||||||
int implicit_use = 0;
|
bool implicit_use = false;
|
||||||
bool anon = !name;
|
bool anon = !name;
|
||||||
|
|
||||||
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
|
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
|
||||||
|
@ -3535,8 +3535,8 @@ push_namespace (tree name)
|
||||||
d = IDENTIFIER_NAMESPACE_VALUE (name);
|
d = IDENTIFIER_NAMESPACE_VALUE (name);
|
||||||
if (d)
|
if (d)
|
||||||
/* Reopening anonymous namespace. */
|
/* Reopening anonymous namespace. */
|
||||||
need_new = 0;
|
need_new = false;
|
||||||
implicit_use = 1;
|
implicit_use = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3544,13 +3544,36 @@ push_namespace (tree name)
|
||||||
d = IDENTIFIER_NAMESPACE_VALUE (name);
|
d = IDENTIFIER_NAMESPACE_VALUE (name);
|
||||||
if (d != NULL_TREE && TREE_CODE (d) == NAMESPACE_DECL)
|
if (d != NULL_TREE && TREE_CODE (d) == NAMESPACE_DECL)
|
||||||
{
|
{
|
||||||
need_new = 0;
|
tree dna = DECL_NAMESPACE_ALIAS (d);
|
||||||
if (DECL_NAMESPACE_ALIAS (d))
|
if (dna)
|
||||||
{
|
{
|
||||||
error ("namespace alias %qD not allowed here, assuming %qD",
|
/* We do some error recovery for, eg, the redeclaration
|
||||||
d, DECL_NAMESPACE_ALIAS (d));
|
of M here:
|
||||||
d = DECL_NAMESPACE_ALIAS (d);
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
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>
|
2012-06-01 Christian Bruel <christian.bruel@st.com>
|
||||||
|
|
||||||
* gcc.dg/spec-options.c: New test.
|
* gcc.dg/spec-options.c: New test.
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
// PR c++/26155
|
||||||
|
|
||||||
|
namespace N
|
||||||
|
{
|
||||||
|
namespace M = N; // { dg-error "previous declaration" }
|
||||||
|
namespace M {} // { dg-error "declaration of namespace" }
|
||||||
|
}
|
Loading…
Reference in New Issue