diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2014-05-16 17:42:23 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2014-05-16 17:42:23 +0000 |
commit | 54674a35bd0a8d231ad314064d5f7bb8a60ef5df (patch) | |
tree | 6613a62722d8d1cf1c1310d7824ae8798f773352 /gcc/cp/parser.c | |
parent | f4e075e7d9b707fcc5cc53a0e3149ac41172e20b (diff) | |
download | gcc-54674a35bd0a8d231ad314064d5f7bb8a60ef5df.zip gcc-54674a35bd0a8d231ad314064d5f7bb8a60ef5df.tar.gz gcc-54674a35bd0a8d231ad314064d5f7bb8a60ef5df.tar.bz2 |
re PR c++/51640 (Misleading error if the type in the catch() is ambiguous)
/cp
2014-05-16 Paolo Carlini <paolo.carlini@oracle.com>
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 <paolo.carlini@oracle.com>
PR c++/51640
* g++.dg/parse/error54.C: New.
From-SVN: r210521
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index dae4393..7d9f81d 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) |