From: Volker Reichelt Date: Thu, 1 Sep 2005 11:32:20 +0000 (+0000) Subject: re PR c++/13377 (unexpected behavior of namespace usage directive) X-Git-Tag: releases/gcc-3.4.5~226 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a7717f5663ad8f88601caae7616524aac656b66;p=thirdparty%2Fgcc.git 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. From-SVN: r103724 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 837e08849394..b054e31a7e6c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-09-01 Volker Reichelt + + PR c++/13377 + * parser.c (cp_parser_lookup_name): Pass LOOKUP_COMPLAIN to + lookup_name_real on final parse. + 2005-08-31 Volker Reichelt PR c++/23586 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 332cc9b0d099..1edbafca7ccd 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13713,6 +13713,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name, bool is_type, bool is_template, bool is_namespace, bool check_dependency) { + int flags = 0; tree decl; tree object_type = parser->context->object_type; @@ -13724,6 +13725,10 @@ cp_parser_lookup_name (cp_parser *parser, tree name, if (name == error_mark_node) return error_mark_node; + if (!cp_parser_parsing_tentatively (parser) + || cp_parser_committed_to_tentative_parse (parser)) + flags |= LOOKUP_COMPLAIN; + /* A template-id has already been resolved; there is no lookup to do. */ if (TREE_CODE (name) == TEMPLATE_ID_EXPR) @@ -13837,8 +13842,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name, /*protect=*/0, is_type); /* Look it up in the enclosing context, too. */ decl = lookup_name_real (name, is_type, /*nonclass=*/0, - is_namespace, - /*flags=*/0); + is_namespace, flags); parser->object_scope = object_type; parser->qualifying_scope = NULL_TREE; if (object_decl) @@ -13847,8 +13851,7 @@ cp_parser_lookup_name (cp_parser *parser, tree name, else { decl = lookup_name_real (name, is_type, /*nonclass=*/0, - is_namespace, - /*flags=*/0); + is_namespace, flags); parser->qualifying_scope = NULL_TREE; parser->object_scope = NULL_TREE; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4f18fa1ad3a2..81e6c9a0c439 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2005-09-01 Volker Reichelt + + PR c++/13377 + * g++.dg/lookup/ambig4.C: New test. + * g++.dg/lookup/ambig5.C: New test. + 2005-08-31 Volker Reichelt PR c++/23639 diff --git a/gcc/testsuite/g++.dg/lookup/ambig4.C b/gcc/testsuite/g++.dg/lookup/ambig4.C index ab1a14518d59..dbe53db02c9d 100644 --- a/gcc/testsuite/g++.dg/lookup/ambig4.C +++ b/gcc/testsuite/g++.dg/lookup/ambig4.C @@ -11,4 +11,4 @@ int i; // { dg-error "declared" } using namespace N; -void foo() { i; } // { dg-error "in this scope|ambiguous" } +void foo() { i; } // { dg-error "undeclared|ambiguous" }