diff options
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a7939c87647..853d789f987 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23252,15 +23252,17 @@ 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; + /* In C++98 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) + template and what is not. In C++11, per the resolution of DR 468, + `template' is allowed in cases where it is not strictly necessary. */ + if (!processing_template_decl + && pedantic && cxx_dialect == cxx98) { cp_token *token = cp_lexer_peek_token (parser->lexer); - error_at (token->location, - "%<template%> (as a disambiguator) is only allowed " - "within templates"); + pedwarn (token->location, OPT_Wpedantic, + "in C++98 %<template%> (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. */ @@ -23274,7 +23276,6 @@ cp_parser_optional_template_keyword (cp_parser *parser) return true; } } - return false; } |