static cp_expr cp_parser_operator_function_id
(cp_parser *);
static cp_expr cp_parser_operator
- (cp_parser *);
+ (cp_parser *, location_t);
/* Templates [gram.temp] */
/*is_namespace=*/false,
/*check_dependency=*/true,
&ambiguous_decls,
- id_expr_token->location);
+ id_expression.get_location ());
/* If the lookup was ambiguous, an error will already have
been issued. */
if (ambiguous_decls)
if (parser->local_variables_forbidden_p
&& local_variable_p (decl))
{
- error_at (id_expr_token->location,
+ error_at (id_expression.get_location (),
"local variable %qD may not appear in this context",
decl.get_value ());
return error_mark_node;
id_expression.get_location ()));
if (error_msg)
cp_parser_error (parser, error_msg);
- decl.set_location (id_expr_token->location);
+ decl.set_location (id_expression.get_location ());
+ decl.set_range (id_expr_token->location, id_expression.get_finish ());
return decl;
}
static cp_expr
cp_parser_operator_function_id (cp_parser* parser)
{
+ location_t start_loc = cp_lexer_peek_token (parser->lexer)->location;
/* Look for the `operator' keyword. */
if (!cp_parser_require_keyword (parser, RID_OPERATOR, RT_OPERATOR))
return error_mark_node;
/* And then the name of the operator itself. */
- return cp_parser_operator (parser);
+ return cp_parser_operator (parser, start_loc);
}
/* Return an identifier node for a user-defined literal operator.
human-readable spelling of the identifier, e.g., `operator +'. */
static cp_expr
-cp_parser_operator (cp_parser* parser)
+cp_parser_operator (cp_parser* parser, location_t start_loc)
{
tree id = NULL_TREE;
cp_token *token;
/* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer);
- location_t start_loc = token->location;
+ location_t end_loc = token->location;
/* Figure out which operator we have. */
enum tree_code op = ERROR_MARK;
break;
/* Consume the `new' or `delete' token. */
- location_t end_loc = cp_lexer_consume_token (parser->lexer)->location;
+ end_loc = cp_lexer_consume_token (parser->lexer)->location;
/* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer);
end_loc = close_token->location;
op = op == NEW_EXPR ? VEC_NEW_EXPR : VEC_DELETE_EXPR;
}
- start_loc = make_location (start_loc, start_loc, end_loc);
consumed = true;
break;
}
matching_parens parens;
parens.consume_open (parser);
/* Look for the matching `)'. */
- parens.require_close (parser);
+ token = parens.require_close (parser);
+ if (token)
+ end_loc = token->location;
op = CALL_EXPR;
consumed = true;
break;
/* Consume the `['. */
cp_lexer_consume_token (parser->lexer);
/* Look for the matching `]'. */
- cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
+ token = cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
+ if (token)
+ end_loc = token->location;
op = ARRAY_REF;
consumed = true;
break;
case CPP_STRING16_USERDEF:
case CPP_STRING32_USERDEF:
{
- tree str, string_tree;
+ cp_expr str;
+ tree string_tree;
int sz, len;
if (cxx_dialect == cxx98)
{
string_tree = USERDEF_LITERAL_VALUE (str);
id = USERDEF_LITERAL_SUFFIX_ID (str);
+ end_loc = str.get_location ();
}
else
{
/* Look for the suffix identifier. */
token = cp_lexer_peek_token (parser->lexer);
if (token->type == CPP_NAME)
- id = cp_parser_identifier (parser);
+ {
+ id = cp_parser_identifier (parser);
+ end_loc = token->location;
+ }
else if (token->type == CPP_KEYWORD)
{
error ("unexpected keyword;"
const char *name = IDENTIFIER_POINTER (id);
id = cp_literal_operator_id (name);
}
- return id;
+ start_loc = make_location (start_loc, start_loc, get_finish (end_loc));
+ return cp_expr (id, start_loc);
}
default:
id = error_mark_node;
}
+ start_loc = make_location (start_loc, start_loc, get_finish (end_loc));
return cp_expr (id, start_loc);
}