From 708340034c7a8f9acddf56d1068351bbb409d565 Mon Sep 17 00:00:00 2001 From: paolo Date: Fri, 16 May 2014 17:42:23 +0000 Subject: /cp 2014-05-16 Paolo Carlini PR c++/51640 * parser.c (cp_parser_diagnose_invalid_type_name): Early return when cp_parser_lookup_name sets ambiguous_decls. /testsuite 2014-05-16 Paolo Carlini PR c++/51640 * g++.dg/parse/error54.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210521 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 12 ++++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/error54.C | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/error54.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5a13125e513..2714cd3e9bb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-05-16 Paolo Carlini + + PR c++/51640 + * parser.c (cp_parser_diagnose_invalid_type_name): Early return + when cp_parser_lookup_name sets ambiguous_decls. + 2014-05-15 Jason Merrill * call.c (print_conversion_rejection): Use loc consistently. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index dae4393d6e2..7d9f81d314f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2880,13 +2880,21 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree scope, tree id, location_t location) { - tree decl, old_scope; + tree decl, old_scope, ambiguous_decls; cp_parser_commit_to_tentative_parse (parser); /* Try to lookup the identifier. */ old_scope = parser->scope; parser->scope = scope; - decl = cp_parser_lookup_name_simple (parser, id, location); + decl = cp_parser_lookup_name (parser, id, none_type, + /*is_template=*/false, + /*is_namespace=*/false, + /*check_dependency=*/true, + &ambiguous_decls, location); parser->scope = old_scope; + if (ambiguous_decls) + /* If the lookup was ambiguous, an error will already have + been issued. */ + return; /* If the lookup found a template-name, it means that the user forgot to specify an argument list. Emit a useful error message. */ if (TREE_CODE (decl) == TEMPLATE_DECL) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7254012ba3e..0b1d9050532 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-05-16 Paolo Carlini + + PR c++/51640 + * g++.dg/parse/error54.C: New. + 2014-05-16 Vladimir Makarov PR rtl-optimization/60969 diff --git a/gcc/testsuite/g++.dg/parse/error54.C b/gcc/testsuite/g++.dg/parse/error54.C new file mode 100644 index 00000000000..b49c76b0057 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error54.C @@ -0,0 +1,19 @@ +// PR c++/51640 + +class ex {}; + +namespace t +{ + class ex2 : public ex {}; +} + +class ex2 : public ex {}; + +void bar() +{ + using namespace t; + + try { + } catch (ex2&) { // { dg-error "reference to 'ex2' is ambiguous" } + } +} -- cgit v1.2.1