diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-18 10:23:22 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-18 10:23:22 +0000 |
commit | 0680da650a36b1b2245bc8d92876dbd243bd311c (patch) | |
tree | 82a1fb5a01a533049b83b6416d9b5e4eef768913 /gcc/cp/parser.c | |
parent | 028d5ac7ffe7bae46aedabc679074b4c80f45df8 (diff) | |
download | gcc-0680da650a36b1b2245bc8d92876dbd243bd311c.tar.gz |
2012-10-18 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 192552 using svnmerge.py
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@192557 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 965bc621277..853d789f987 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23252,9 +23252,29 @@ cp_parser_optional_template_keyword (cp_parser *parser) { if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TEMPLATE)) { - /* Consume the `template' keyword. */ - cp_lexer_consume_token (parser->lexer); - return true; + /* 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. 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); + 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. */ + cp_lexer_purge_token (parser->lexer); + return false; + } + else + { + /* Consume the `template' keyword. */ + cp_lexer_consume_token (parser->lexer); + return true; + } } return false; } |