From: Jason Merrill Date: Fri, 17 Feb 2017 22:05:18 +0000 (-0500) Subject: PR c++/79508 - lookup error with member template X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cb94c7007c6375f7e6752e0426a5ea0e3f046c47;p=gcc.git PR c++/79508 - lookup error with member template * parser.c (cp_parser_template_name): Clear parser->context->object_type if we aren't doing lookup. From-SVN: r245553 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2e2cd6c48c5..8dce6d18fea 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-02-17 Jason Merrill + PR c++/79508 - lookup error with member template + * parser.c (cp_parser_template_name): Clear + parser->context->object_type if we aren't doing lookup. + PR c++/78690 - ICE with using and global type with same name * pt.c (type_dependent_object_expression_p): True for IDENTIFIER_NODE. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 060962db625..92d8ccea95b 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15719,6 +15719,7 @@ cp_parser_template_name (cp_parser* parser, cp_lexer_purge_tokens_after (parser->lexer, start); if (is_identifier) *is_identifier = true; + parser->context->object_type = NULL_TREE; return identifier; } @@ -15730,7 +15731,12 @@ cp_parser_template_name (cp_parser* parser, && (!parser->scope || (TYPE_P (parser->scope) && dependent_type_p (parser->scope)))) - return identifier; + { + /* We're optimizing away the call to cp_parser_lookup_name, but we + still need to do this. */ + parser->context->object_type = NULL_TREE; + return identifier; + } } /* Look up the name. */ diff --git a/gcc/testsuite/g++.dg/template/memtmpl5.C b/gcc/testsuite/g++.dg/template/memtmpl5.C new file mode 100644 index 00000000000..c5c3634ff38 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/memtmpl5.C @@ -0,0 +1,22 @@ +// PR c++/79508 + +struct C +{ + template< void(*F)()> void set_default() { } +}; + + +template void random_positive() +{ +} + +template void initialize(T& x) +{ + x.template set_default >(); +} + +int main () +{ + C x; + initialize(x); +}