Commit f746161e by Mark Mitchell Committed by Mark Mitchell

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
parent 3972995b
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> 2004-05-23 Gabriel Dos Reis <gdr@integrable-solutions.net>
* class.c (alter_access): Use %E format specifier to print an * class.c (alter_access): Use %E format specifier to print an
......
...@@ -503,11 +503,22 @@ supplement_binding (cxx_binding *binding, tree decl) ...@@ -503,11 +503,22 @@ supplement_binding (cxx_binding *binding, tree decl)
duplicate_decls (decl, binding->value); duplicate_decls (decl, binding->value);
ok = false; 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 else
{ {
error ("declaration of `%#D'", decl); error ("declaration of `%#D'", decl);
cp_error_at ("conflicts with previous declaration `%#D'", cp_error_at ("conflicts with previous declaration `%#D'", bval);
binding->value);
ok = false; ok = false;
} }
......
...@@ -8417,7 +8417,11 @@ cp_parser_template_argument (cp_parser* parser) ...@@ -8417,7 +8417,11 @@ cp_parser_template_argument (cp_parser* parser)
cp_parser_error (parser, "expected template-argument"); cp_parser_error (parser, "expected template-argument");
if (!cp_parser_error_occurred (parser)) if (!cp_parser_error_occurred (parser))
{ {
/* Figure out what is being referred to. */ /* 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, argument = cp_parser_lookup_name (parser, argument,
/*is_type=*/false, /*is_type=*/false,
/*is_template=*/template_p, /*is_template=*/template_p,
......
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> 2004-05-23 Paul Brook <paul@codesourcery.com>
Victor Leikehman <lei@haifasphere.co.il> Victor Leikehman <lei@haifasphere.co.il>
......
// PR c++/14821
namespace A {
namespace B {}
}
namespace A {
namespace Alias = ::A::B;
}
namespace A {
namespace Alias = ::A::B;
}
// 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 "" }
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