summaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-15 17:11:32 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-15 17:11:32 +0000
commit0fb3af46a9812808184394522ff6d65089d3f9bb (patch)
tree4758c5c96ba58a9277e874c67cdf097af9b94edd /gcc/cp/parser.c
parentd0d9fa3b225da0716148b9879b699c6014a626c2 (diff)
downloadgcc-0fb3af46a9812808184394522ff6d65089d3f9bb.tar.gz
2012-10-15 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 192465 using svnmerge.py git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@192466 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index e2b355a246f..965bc621277 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -8718,7 +8718,17 @@ cp_parser_statement (cp_parser* parser, tree in_statement_expr,
cp_lexer_save_tokens (parser->lexer);
attrs_location = cp_lexer_peek_token (parser->lexer)->location;
+ if (c_dialect_objc ())
+ /* In obj-c++, seing '[[' might be the either the beginning of
+ c++11 attributes, or a nested objc-message-expression. So
+ let's parse the c++11 attributes tentatively. */
+ cp_parser_parse_tentatively (parser);
std_attrs = cp_parser_std_attribute_spec_seq (parser);
+ if (c_dialect_objc ())
+ {
+ if (!cp_parser_parse_definitely (parser))
+ std_attrs = NULL_TREE;
+ }
/* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer);
@@ -20703,7 +20713,6 @@ cp_parser_std_attribute_spec (cp_parser *parser)
&& cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_OPEN_SQUARE)
{
cp_lexer_consume_token (parser->lexer);
- maybe_warn_cpp0x (CPP0X_ATTRIBUTES);
cp_lexer_consume_token (parser->lexer);
attributes = cp_parser_std_attribute_list (parser);
@@ -20711,6 +20720,10 @@ cp_parser_std_attribute_spec (cp_parser *parser)
if (!cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE)
|| !cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE))
cp_parser_skip_to_end_of_statement (parser);
+ else
+ /* Warn about parsing c++11 attribute in non-c++1 mode, only
+ when we are sure that we have actually parsed them. */
+ maybe_warn_cpp0x (CPP0X_ATTRIBUTES);
}
else
{
@@ -23239,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,
- "%<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;
- }
+ /* Consume the `template' keyword. */
+ cp_lexer_consume_token (parser->lexer);
+ return true;
}
-
return false;
}