extern bool vague_linkage_p (tree);
extern void grokclassfn (tree, tree,
enum overload_flags);
-extern tree grok_array_decl (location_t, tree, tree);
+extern tree grok_array_decl (location_t, tree, tree, bool);
extern tree delete_sanity (tree, tree, bool, int, tsubst_flags_t);
extern tree check_classfn (tree, tree, tree);
extern void check_member_template (tree);
extern tree finish_increment_expr (tree, enum tree_code);
extern tree finish_this_expr (void);
extern tree finish_pseudo_destructor_expr (tree, tree, tree);
-extern tree finish_unary_op_expr (location_t, enum tree_code, tree);
+extern tree finish_unary_op_expr (location_t, enum tree_code, tree,
+ tsubst_flags_t);
extern tree finish_compound_literal (tree, tree, tsubst_flags_t);
extern tree finish_fname (tree);
extern void finish_translation_unit (void);
}
/* Create an ARRAY_REF, checking for the user doing things backwards
- along the way. */
+ along the way. DECLTYPE_P is for N3276, as in the parser. */
tree
-grok_array_decl (location_t loc, tree array_expr, tree index_exp)
+grok_array_decl (location_t loc, tree array_expr, tree index_exp,
+ bool decltype_p)
{
tree type;
tree expr;
/* If they have an `operator[]', use that. */
if (MAYBE_CLASS_TYPE_P (type) || MAYBE_CLASS_TYPE_P (TREE_TYPE (index_exp)))
- expr = build_new_op (loc, ARRAY_REF, LOOKUP_NORMAL, array_expr, index_exp,
- NULL_TREE, /*overload=*/NULL, tf_warning_or_error);
+ {
+ tsubst_flags_t complain = tf_warning_or_error;
+ if (decltype_p)
+ complain |= tf_decltype;
+ expr = build_new_op (loc, ARRAY_REF, LOOKUP_NORMAL, array_expr,
+ index_exp, NULL_TREE, /*overload=*/NULL, complain);
+ }
else
{
tree p1, p2, i1, i2;
static tree cp_parser_postfix_expression
(cp_parser *, bool, bool, bool, bool, cp_id_kind *);
static tree cp_parser_postfix_open_square_expression
- (cp_parser *, tree, bool);
+ (cp_parser *, tree, bool, bool);
static tree cp_parser_postfix_dot_deref_expression
(cp_parser *, enum cpp_ttype, tree, bool, cp_id_kind *, location_t);
static vec<tree, va_gc> *cp_parser_parenthesized_expression_list
return success;
}
+/* Return the appropriate tsubst flags for parsing, possibly in N3276
+ decltype context. */
+
+static inline tsubst_flags_t
+complain_flags (bool decltype_p)
+{
+ tsubst_flags_t complain = tf_warning_or_error;
+ if (decltype_p)
+ complain |= tf_decltype;
+ return complain;
+}
+
/* Expressions [gram.expr] */
/* Parse a primary-expression.
postfix_expression
= cp_parser_postfix_open_square_expression (parser,
postfix_expression,
- false);
+ false,
+ decltype_p);
idk = CP_ID_KIND_NONE;
is_member_access = false;
break;
bool is_builtin_constant_p;
bool saved_integral_constant_expression_p = false;
bool saved_non_integral_constant_expression_p = false;
- int complain = tf_warning_or_error;
+ tsubst_flags_t complain = complain_flags (decltype_p);
vec<tree, va_gc> *args;
- if (decltype_p)
- complain |= tf_decltype;
-
is_member_access = false;
is_builtin_constant_p
static tree
cp_parser_postfix_open_square_expression (cp_parser *parser,
tree postfix_expression,
- bool for_offsetof)
+ bool for_offsetof,
+ bool decltype_p)
{
tree index;
location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
/* Build the ARRAY_REF. */
- postfix_expression = grok_array_decl (loc, postfix_expression, index);
+ postfix_expression = grok_array_decl (loc, postfix_expression,
+ index, decltype_p);
/* When not doing offsetof, array references are not permitted in
constant-expressions. */
tree expression = error_mark_node;
non_integral_constant non_constant_p = NIC_NONE;
location_t loc = token->location;
+ tsubst_flags_t complain = complain_flags (decltype_p);
/* Consume the operator token. */
token = cp_lexer_consume_token (parser->lexer);
non_constant_p = NIC_STAR;
expression = build_x_indirect_ref (loc, cast_expression,
RO_UNARY_STAR,
- tf_warning_or_error);
+ complain);
break;
case ADDR_EXPR:
case BIT_NOT_EXPR:
expression = build_x_unary_op (loc, unary_operator,
cast_expression,
- tf_warning_or_error);
+ complain);
break;
case PREINCREMENT_EXPR:
case NEGATE_EXPR:
case TRUTH_NOT_EXPR:
expression = finish_unary_op_expr (loc, unary_operator,
- cast_expression);
+ cast_expression, complain);
break;
default:
current.lhs = build_x_binary_op (current.loc, current.tree_type,
current.lhs, current.lhs_type,
rhs, rhs_type, &overload,
- tf_warning_or_error);
+ complain_flags (decltype_p));
current.lhs_type = current.tree_type;
if (EXPR_P (current.lhs))
SET_EXPR_LOCATION (current.lhs, current.loc);
expr = build_x_modify_expr (loc, expr,
assignment_operator,
rhs,
- tf_warning_or_error);
+ complain_flags (decltype_p));
input_location = saved_input_location;
}
}
else
expression = build_x_compound_expr (loc, expression,
assignment_expression,
- tf_warning_or_error);
+ complain_flags (decltype_p));
/* If the next token is not a comma, then we are done with the
expression. */
if (cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA))
{
case CPP_OPEN_SQUARE:
/* offsetof-member-designator "[" expression "]" */
- expr = cp_parser_postfix_open_square_expression (parser, expr, true);
+ expr = cp_parser_postfix_open_square_expression (parser, expr,
+ true, false);
break;
case CPP_DEREF:
/* offsetof-member-designator "->" identifier */
- expr = grok_array_decl (token->location, expr, integer_zero_node);
+ expr = grok_array_decl (token->location, expr,
+ integer_zero_node, false);
/* FALLTHRU */
case CPP_DOT:
/* The new increment expression. */
expression = finish_unary_op_expr (input_location,
- PREINCREMENT_EXPR, begin);
+ PREINCREMENT_EXPR, begin,
+ tf_warning_or_error);
finish_for_expr (expression, statement);
/* The declaration is initialized with *__begin inside the loop body. */