return cp_lexer_peek_token (lexer)->keyword == keyword;
}
+static inline bool
+cp_lexer_nth_token_is_keyword (cp_lexer* lexer, size_t n, enum rid keyword)
+{
+ return cp_lexer_peek_nth_token (lexer, n)->keyword == keyword;
+}
+
/* Return true if the next token is not the indicated KEYWORD. */
static inline bool
/* Values for the second parameter of cp_parser_parenthesized_expression_list. */
enum { non_attr = 0, normal_attr = 1, id_attr = 2 };
static void cp_parser_pseudo_destructor_name
- (cp_parser *, tree *, tree *);
+ (cp_parser *, tree, tree *, tree *);
static tree cp_parser_unary_expression
(cp_parser *, bool, bool, cp_id_kind *);
static enum tree_code cp_parser_unary_operator
return build_nt (BIT_NOT_EXPR, scope);
}
+ /* ~auto means the destructor of whatever the object is. */
+ if (cp_parser_is_keyword (token, RID_AUTO))
+ {
+ if (cxx_dialect < cxx1y)
+ pedwarn (input_location, 0,
+ "%<~auto%> only available with "
+ "-std=c++1y or -std=gnu++1y");
+ cp_lexer_consume_token (parser->lexer);
+ return build_nt (BIT_NOT_EXPR, make_auto ());
+ }
+
/* If there was an explicit qualification (S::~T), first look
in the scope given by the qualification (i.e., S).
cp_parser_parse_tentatively (parser);
/* Parse the pseudo-destructor-name. */
s = NULL_TREE;
- cp_parser_pseudo_destructor_name (parser, &s, &type);
+ cp_parser_pseudo_destructor_name (parser, postfix_expression,
+ &s, &type);
if (dependent_p
&& (cp_parser_error_occurred (parser)
- || TREE_CODE (type) != TYPE_DECL
- || !SCALAR_TYPE_P (TREE_TYPE (type))))
+ || !SCALAR_TYPE_P (type)))
cp_parser_abort_tentative_parse (parser);
else if (cp_parser_parse_definitely (parser))
{
pseudo_destructor_p = true;
postfix_expression
= finish_pseudo_destructor_expr (postfix_expression,
- s, TREE_TYPE (type));
+ s, type);
}
}
static void
cp_parser_pseudo_destructor_name (cp_parser* parser,
+ tree object,
tree* scope,
tree* type)
{
bool nested_name_specifier_p;
+ /* Handle ~auto. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_COMPL)
+ && cp_lexer_nth_token_is_keyword (parser->lexer, 2, RID_AUTO)
+ && !type_dependent_expression_p (object))
+ {
+ if (cxx_dialect < cxx1y)
+ pedwarn (input_location, 0,
+ "%<~auto%> only available with "
+ "-std=c++1y or -std=gnu++1y");
+ cp_lexer_consume_token (parser->lexer);
+ cp_lexer_consume_token (parser->lexer);
+ *scope = NULL_TREE;
+ *type = TREE_TYPE (object);
+ return;
+ }
+
/* Assume that things will not work out. */
*type = error_mark_node;
/* Look for the type-name again. We are not responsible for
checking that it matches the first type-name. */
- *type = cp_parser_nonclass_name (parser);
+ *type = TREE_TYPE (cp_parser_nonclass_name (parser));
}
/* Parse a unary-expression.