From: jason Date: Wed, 15 Jul 2015 14:13:22 +0000 (+0000) Subject: PR c++/65091 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c9b2637ddd86d987b2122207eb41bb7bb21734f5;p=thirdparty%2Fgcc.git PR c++/65091 * parser.c (cp_parser_unqualified_id): Don't accept ~x in a template if there is no type x in scope. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225831 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 00cbe47dfa42..6b92826118e4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-07-15 Jason Merrill + + PR c++/65091 + * parser.c (cp_parser_unqualified_id): Don't accept ~x in a + template if there is no type x in scope. + 2015-07-14 Patrick Palka PR c++/66850 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 574ffba3ecec..f1d5656055ce 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5162,8 +5162,15 @@ cp_parser_unqualified_id (cp_parser* parser, if (processing_template_decl && ! cp_parser_parse_definitely (parser)) { - /* We couldn't find a type with this name, so just accept - it and check for a match at instantiation time. */ + /* We couldn't find a type with this name. If we're parsing + tentatively, fail and try something else. */ + if (cp_parser_uncommitted_to_tentative_parse_p (parser)) + { + cp_parser_simulate_error (parser); + return error_mark_node; + } + /* Otherwise, accept it and check for a match at instantiation + time. */ type_decl = cp_parser_identifier (parser); if (type_decl != error_mark_node) type_decl = build_nt (BIT_NOT_EXPR, type_decl); diff --git a/gcc/testsuite/g++.dg/parse/dtor17.C b/gcc/testsuite/g++.dg/parse/dtor17.C new file mode 100644 index 000000000000..1fca4132b87f --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/dtor17.C @@ -0,0 +1,11 @@ +// PR c++/65091 +// { dg-do compile { target c++11 } } + +template +auto foo(T x) -> decltype(~x) { + return ~x; +} + +int bar() { + return foo(10); +}