diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2012-06-01 16:11:38 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2012-06-01 16:11:38 +0000 |
commit | 5714705f1189d42e55c4209e2d2485c9d3bea1cd (patch) | |
tree | 54a3eea2e026357457e9e32423fe45b7c32e0a5f /gcc/cp | |
parent | 874a3589497f78b4631ee273b4bc5dd8293e3873 (diff) | |
download | gcc-5714705f1189d42e55c4209e2d2485c9d3bea1cd.zip gcc-5714705f1189d42e55c4209e2d2485c9d3bea1cd.tar.gz gcc-5714705f1189d42e55c4209e2d2485c9d3bea1cd.tar.bz2 |
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
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 43 |
2 files changed, 39 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b1f0734..95e698d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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> * call.c: Do not include output.h. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 6930502..642f39f 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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; } } |