* cp-tree.h (struct cp_evaluated): New.
This patch simplifies the saving/clearing/restoring of
cp_unevaluated_operand and c_inhibit_evaluation_warnings in the presence of
mid-block returns.
* init.c (get_nsdmi): Use it.
* parser.c (cp_parser_enclosed_template_argument_list): Use it.
* pt.c (coerce_template_parms, tsubst_aggr_type): Use it.
From-SVN: r266051
+2018-11-12 Jason Merrill <jason@redhat.com>
+
+ * cp-tree.h (struct cp_evaluated): New.
+ * init.c (get_nsdmi): Use it.
+ * parser.c (cp_parser_enclosed_template_argument_list): Use it.
+ * pt.c (coerce_template_parms, tsubst_aggr_type): Use it.
+
2018-11-09 Jakub Jelinek <jakub@redhat.com>
* parser.c (cp_parser_omp_clause_final, cp_parser_omp_clause_if): Use
~cp_unevaluated ();
};
+/* The reverse: an RAII class used for nested contexts that are evaluated even
+ if the enclosing context is not. */
+
+struct cp_evaluated
+{
+ int uneval;
+ int inhibit;
+ cp_evaluated ()
+ : uneval(cp_unevaluated_operand), inhibit(c_inhibit_evaluation_warnings)
+ { cp_unevaluated_operand = c_inhibit_evaluation_warnings = 0; }
+ ~cp_evaluated ()
+ { cp_unevaluated_operand = uneval;
+ c_inhibit_evaluation_warnings = inhibit; }
+};
+
/* in pt.c */
/* These values are used for the `STRICT' parameter to type_unification and
}
else
{
- int un = cp_unevaluated_operand;
- cp_unevaluated_operand = 0;
+ cp_evaluated ev;
location_t sloc = input_location;
input_location = expr_loc;
}
input_location = sloc;
- cp_unevaluated_operand = un;
}
}
else
tree saved_qualifying_scope;
tree saved_object_scope;
bool saved_greater_than_is_operator_p;
- int saved_unevaluated_operand;
- int saved_inhibit_evaluation_warnings;
/* [temp.names]
saved_object_scope = parser->object_scope;
/* We need to evaluate the template arguments, even though this
template-id may be nested within a "sizeof". */
- saved_unevaluated_operand = cp_unevaluated_operand;
- cp_unevaluated_operand = 0;
- saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings;
- c_inhibit_evaluation_warnings = 0;
+ cp_evaluated ev;
/* Parse the template-argument-list itself. */
if (cp_lexer_next_token_is (parser->lexer, CPP_GREATER)
|| cp_lexer_next_token_is (parser->lexer, CPP_RSHIFT))
parser->scope = saved_scope;
parser->qualifying_scope = saved_qualifying_scope;
parser->object_scope = saved_object_scope;
- cp_unevaluated_operand = saved_unevaluated_operand;
- c_inhibit_evaluation_warnings = saved_inhibit_evaluation_warnings;
return arguments;
}
tree inner_args;
tree new_args;
tree new_inner_args;
- int saved_unevaluated_operand;
- int saved_inhibit_evaluation_warnings;
/* When used as a boolean value, indicates whether this is a
variadic template parameter list. Since it's an int, we can also
/* We need to evaluate the template arguments, even though this
template-id may be nested within a "sizeof". */
- saved_unevaluated_operand = cp_unevaluated_operand;
- cp_unevaluated_operand = 0;
- saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings;
- c_inhibit_evaluation_warnings = 0;
+ cp_evaluated ev;
+
new_inner_args = make_tree_vec (nparms);
new_args = add_outermost_template_args (args, new_inner_args);
int pack_adjust = 0;
lost++;
TREE_VEC_ELT (new_inner_args, arg_idx - pack_adjust) = arg;
}
- cp_unevaluated_operand = saved_unevaluated_operand;
- c_inhibit_evaluation_warnings = saved_inhibit_evaluation_warnings;
if (missing || arg_idx < nargs - variadic_args_p)
{
tree argvec;
tree context;
tree r;
- int saved_unevaluated_operand;
- int saved_inhibit_evaluation_warnings;
/* In "sizeof(X<I>)" we need to evaluate "I". */
- saved_unevaluated_operand = cp_unevaluated_operand;
- cp_unevaluated_operand = 0;
- saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings;
- c_inhibit_evaluation_warnings = 0;
+ cp_evaluated ev;
/* First, determine the context for the type we are looking
up. */
r = cp_build_qualified_type_real (r, cp_type_quals (t), complain);
}
- cp_unevaluated_operand = saved_unevaluated_operand;
- c_inhibit_evaluation_warnings = saved_inhibit_evaluation_warnings;
-
return r;
}
else