From: Paolo Carlini Date: Mon, 15 Oct 2012 16:47:52 +0000 (+0000) Subject: re PR c++/50080 ([DR 468] error: 'template' (as a disambiguator) is only allowed... X-Git-Tag: upstream/12.2.0~73558 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81833173943fec6dec7287b475303e9d22387386;p=platform%2Fupstream%2Fgcc.git re PR c++/50080 ([DR 468] error: 'template' (as a disambiguator) is only allowed within templates) /cp 2012-10-15 Paolo Carlini PR c++/50080 * parser.c (cp_parser_optional_template_keyword): Implement Core/468, allow outside template. /testsuite 2012-10-15 Paolo Carlini PR c++/50080 * g++.dg/parse/tmpl-outside2.C: New. * g++.dg/parse/tmpl-outside1.C: Adjust. * g++.dg/template/qualttp18.C: Likewise. * g++.old-deja/g++.pt/memtemp87.C: Likewise. * g++.old-deja/g++.pt/overload13.C: Likewise. From-SVN: r192465 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6621c114899..5239e7e33cf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-10-15 Paolo Carlini + + PR c++/50080 + * parser.c (cp_parser_optional_template_keyword): Implement + Core/468, allow outside template. + 2012-10-14 Jason Merrill Ville Voutilainen diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a7939c87647..965bc621277 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23252,29 +23252,10 @@ cp_parser_optional_template_keyword (cp_parser *parser) { if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TEMPLATE)) { - /* The `template' keyword can only be used within templates; - outside templates the parser can always figure out what is a - template and what is not. */ - if (!processing_template_decl) - { - cp_token *token = cp_lexer_peek_token (parser->lexer); - error_at (token->location, - "% (as a disambiguator) is only allowed " - "within templates"); - /* If this part of the token stream is rescanned, the same - error message would be generated. So, we purge the token - from the stream. */ - cp_lexer_purge_token (parser->lexer); - return false; - } - else - { - /* Consume the `template' keyword. */ - cp_lexer_consume_token (parser->lexer); - return true; - } + /* Consume the `template' keyword. */ + cp_lexer_consume_token (parser->lexer); + return true; } - return false; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 74e7b1c3fd6..38055629b88 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2012-10-15 Paolo Carlini + + PR c++/50080 + * g++.dg/parse/tmpl-outside2.C: New. + * g++.dg/parse/tmpl-outside1.C: Adjust. + * g++.dg/template/qualttp18.C: Likewise. + * g++.old-deja/g++.pt/memtemp87.C: Likewise. + * g++.old-deja/g++.pt/overload13.C: Likewise. + 2012-10-15 Marc Glisse PR tree-optimization/54915 diff --git a/gcc/testsuite/g++.dg/parse/tmpl-outside1.C b/gcc/testsuite/g++.dg/parse/tmpl-outside1.C index e63e3cd4412..0713f170aa0 100644 --- a/gcc/testsuite/g++.dg/parse/tmpl-outside1.C +++ b/gcc/testsuite/g++.dg/parse/tmpl-outside1.C @@ -7,4 +7,4 @@ struct X template struct Y {}; }; -typedef X::template Y<0> y; // { dg-error "template|invalid" } +typedef X::template Y<0> y; diff --git a/gcc/testsuite/g++.dg/parse/tmpl-outside2.C b/gcc/testsuite/g++.dg/parse/tmpl-outside2.C new file mode 100644 index 00000000000..d35656f609e --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/tmpl-outside2.C @@ -0,0 +1,19 @@ +// PR c++/50080 + +template +struct A +{ + template + struct B {}; +}; + +template +void test() +{ + typename A::template B b; +} + +int main() +{ + typename A::template B b; +} diff --git a/gcc/testsuite/g++.dg/template/qualttp18.C b/gcc/testsuite/g++.dg/template/qualttp18.C index 31dfa6a83d0..b4d28da5980 100644 --- a/gcc/testsuite/g++.dg/template/qualttp18.C +++ b/gcc/testsuite/g++.dg/template/qualttp18.C @@ -14,7 +14,7 @@ template