diff options
author | Mark Mitchell <mark@codesourcery.com> | 2004-05-23 17:56:26 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2004-05-23 17:56:26 +0000 |
commit | f746161e4ffa1427f1b2c7b08fafaad3046a9222 (patch) | |
tree | 939b992140fb6e653d3be72640963ab2c43bbe46 | |
parent | 3972995b195de4ecd0055f63351987a128546208 (diff) | |
download | gcc-f746161e4ffa1427f1b2c7b08fafaad3046a9222.zip gcc-f746161e4ffa1427f1b2c7b08fafaad3046a9222.tar.gz gcc-f746161e4ffa1427f1b2c7b08fafaad3046a9222.tar.bz2 |
re PR c++/14821 (Duplicate namespace alias declaration should not conflict)
PR c++/14821
* name-lookup.c (supplement_binding): Allow redefinitions of
namespace aliases.
PR c++/14883
* parser.c (cp_parser_template_argument): Robustify.
PR c++/14821
* g++.dg/other/ns1.C: New test.
PR c++/14883
* g++.dg/template/invalid1.C: New test.
From-SVN: r82170
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 15 | ||||
-rw-r--r-- | gcc/cp/parser.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/ns1.C | 13 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/invalid1.C | 7 |
6 files changed, 60 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3878c7e..e6a6524 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2004-05-23 Mark Mitchell <mark@codesourcery.com> + + PR c++/14821 + * name-lookup.c (supplement_binding): Allow redefinitions of + namespace aliases. + + PR c++/14883 + * parser.c (cp_parser_template_argument): Robustify. + 2004-05-23 Gabriel Dos Reis <gdr@integrable-solutions.net> * class.c (alter_access): Use %E format specifier to print an diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 3888834..ad8003d 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -503,11 +503,22 @@ supplement_binding (cxx_binding *binding, tree decl) duplicate_decls (decl, binding->value); ok = false; } + else if (TREE_CODE (decl) == NAMESPACE_DECL + && TREE_CODE (bval) == NAMESPACE_DECL + && DECL_NAMESPACE_ALIAS (decl) + && DECL_NAMESPACE_ALIAS (bval) + && ORIGINAL_NAMESPACE (bval) == ORIGINAL_NAMESPACE (decl)) + /* [namespace.alias] + + In a declarative region, a namespace-alias-definition can be + used to redefine a namespace-alias declared in that declarative + region to refer only to the namespace to which it already + refers. */ + ok = false; else { error ("declaration of `%#D'", decl); - cp_error_at ("conflicts with previous declaration `%#D'", - binding->value); + cp_error_at ("conflicts with previous declaration `%#D'", bval); ok = false; } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d26061f..59ef23f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8417,12 +8417,16 @@ cp_parser_template_argument (cp_parser* parser) cp_parser_error (parser, "expected template-argument"); if (!cp_parser_error_occurred (parser)) { - /* Figure out what is being referred to. */ - argument = cp_parser_lookup_name (parser, argument, - /*is_type=*/false, - /*is_template=*/template_p, - /*is_namespace=*/false, - /*check_dependency=*/true); + /* Figure out what is being referred to. If the id-expression + was for a class template specialization, then we will have a + TYPE_DECL at this point. There is no need to do name lookup + at this point in that case. */ + if (TREE_CODE (argument) != TYPE_DECL) + argument = cp_parser_lookup_name (parser, argument, + /*is_type=*/false, + /*is_template=*/template_p, + /*is_namespace=*/false, + /*check_dependency=*/true); if (TREE_CODE (argument) != TEMPLATE_DECL && TREE_CODE (argument) != UNBOUND_CLASS_TEMPLATE) cp_parser_error (parser, "expected template-name"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5feef48..d93b5c9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2004-05-23 Mark Mitchell <mark@codesourcery.com> + + PR c++/14821 + * g++.dg/other/ns1.C: New test. + + PR c++/14883 + * g++.dg/template/invalid1.C: New test. + 2004-05-23 Paul Brook <paul@codesourcery.com> Victor Leikehman <lei@haifasphere.co.il> diff --git a/gcc/testsuite/g++.dg/other/ns1.C b/gcc/testsuite/g++.dg/other/ns1.C new file mode 100644 index 0000000..cb77780 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ns1.C @@ -0,0 +1,13 @@ +// PR c++/14821 + +namespace A { + namespace B {} +} + +namespace A { + namespace Alias = ::A::B; +} + +namespace A { + namespace Alias = ::A::B; +} diff --git a/gcc/testsuite/g++.dg/template/invalid1.C b/gcc/testsuite/g++.dg/template/invalid1.C new file mode 100644 index 0000000..04b8710 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/invalid1.C @@ -0,0 +1,7 @@ +// PR c++/14883 + +template < class T > struct DomainTraits {}; +template < int Dim > class Interval; +template < class DT > class Domain {}; +template <> class Interval < 1 >:public Domain < DomainTraits < Interval < 1 > +>> {}; // { dg-error "" } |