Commit ef07d61b by Volker Reichelt Committed by Volker Reichelt

re PR c++/13377 (unexpected behavior of namespace usage directive)

	PR c++/13377
	* parser.c (cp_parser_lookup_name): Pass LOOKUP_COMPLAIN to
	lookup_name_real on final parse.

	* g++.dg/lookup/ambig4.C: New test.
	* g++.dg/lookup/ambig5.C: New test.
	* g++.dg/tc1/dr101.C: Adjust error markers.

From-SVN: r103667
parent 1e1b4b37
2005-08-31 Volker Reichelt <reichelt@igpm.rwth-aachen.de> 2005-08-31 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/13377
* parser.c (cp_parser_lookup_name): Pass LOOKUP_COMPLAIN to
lookup_name_real on final parse.
2005-08-31 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/23639 PR c++/23639
* semantics.c (qualified_name_lookup_error): Do not complain again * semantics.c (qualified_name_lookup_error): Do not complain again
on invalid scope. on invalid scope.
......
...@@ -14464,9 +14464,13 @@ cp_parser_lookup_name (cp_parser *parser, tree name, ...@@ -14464,9 +14464,13 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
bool check_dependency, bool check_dependency,
bool *ambiguous_p) bool *ambiguous_p)
{ {
int flags = 0;
tree decl; tree decl;
tree object_type = parser->context->object_type; tree object_type = parser->context->object_type;
if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
flags |= LOOKUP_COMPLAIN;
/* Assume that the lookup will be unambiguous. */ /* Assume that the lookup will be unambiguous. */
if (ambiguous_p) if (ambiguous_p)
*ambiguous_p = false; *ambiguous_p = false;
...@@ -14599,8 +14603,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name, ...@@ -14599,8 +14603,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
/* Look it up in the enclosing context, too. */ /* Look it up in the enclosing context, too. */
decl = lookup_name_real (name, tag_type != none_type, decl = lookup_name_real (name, tag_type != none_type,
/*nonclass=*/0, /*nonclass=*/0,
/*block_p=*/true, is_namespace, /*block_p=*/true, is_namespace, flags);
/*flags=*/0);
parser->object_scope = object_type; parser->object_scope = object_type;
parser->qualifying_scope = NULL_TREE; parser->qualifying_scope = NULL_TREE;
if (object_decl) if (object_decl)
...@@ -14610,8 +14613,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name, ...@@ -14610,8 +14613,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
{ {
decl = lookup_name_real (name, tag_type != none_type, decl = lookup_name_real (name, tag_type != none_type,
/*nonclass=*/0, /*nonclass=*/0,
/*block_p=*/true, is_namespace, /*block_p=*/true, is_namespace, flags);
/*flags=*/0);
parser->qualifying_scope = NULL_TREE; parser->qualifying_scope = NULL_TREE;
parser->object_scope = NULL_TREE; parser->object_scope = NULL_TREE;
} }
......
2005-08-31 Volker Reichelt <reichelt@igpm.rwth-aachen.de> 2005-08-31 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/13377
* g++.dg/lookup/ambig4.C: New test.
* g++.dg/lookup/ambig5.C: New test.
* g++.dg/tc1/dr101.C: Adjust error markers.
2005-08-31 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/23639 PR c++/23639
* g++.dg/template/ttp5.C: Adjust error markers. * g++.dg/template/ttp5.C: Adjust error markers.
// PR c++/13377
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
// { dg-do compile }
namespace N
{
int i; // { dg-error "declared" }
}
int i; // { dg-error "declared" }
using namespace N;
void foo() { i; } // { dg-error "in this scope|ambiguous" }
// PR c++/13377
// Origin: Boris Kolpackov <boris@kolpackov.net>
// { dg-do compile }
namespace N
{
namespace M {} // { dg-error "declared" }
}
namespace M {} // { dg-error "declared" }
using namespace N;
using namespace M; // { dg-error "namespace-name|ambiguous" }
...@@ -17,10 +17,10 @@ namespace Test1 { ...@@ -17,10 +17,10 @@ namespace Test1 {
namespace Test2 { namespace Test2 {
typedef unsigned int X; typedef unsigned int X; // { dg-bogus "declared" "" { xfail *-*-* } }
extern "C" int f2(); extern "C" int f2();
namespace N { namespace N {
typedef unsigned int X; typedef unsigned int X; // { dg-bogus "declared" "" { xfail *-*-* } }
extern "C" int f2(); extern "C" int f2();
} }
using namespace N; using namespace N;
......
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