#include "cp-tree.h"
#include "flags.h"
#include "target.h"
-#include "gimple.h"
#include "gimplify.h"
#include "wide-int.h"
TREE_READONLY (exp) = was_const;
TREE_THIS_VOLATILE (exp) = was_volatile;
TREE_TYPE (exp) = type;
- if (init)
+ /* Restore the type of init unless it was used directly. */
+ if (init && TREE_CODE (stmt_expr) != INIT_EXPR)
TREE_TYPE (init) = itype;
return stmt_expr;
}
{
if (complain & tf_error)
{
- error_at (EXPR_LOC_OR_HERE (inner_nelts),
+ error_at (EXPR_LOC_OR_LOC (inner_nelts, input_location),
"array size in operator new must be constant");
cxx_constant_value(inner_nelts);
}
&& !TREE_CONSTANT (maybe_constant_value (outer_nelts)))
{
if (complain & tf_warning_or_error)
- pedwarn(EXPR_LOC_OR_HERE (outer_nelts), OPT_Wvla,
+ pedwarn(EXPR_LOC_OR_LOC (outer_nelts, input_location), OPT_Wvla,
"ISO C++ does not support variable-length array types");
else
return error_mark_node;
}
/* Perform the overflow check. */
tree errval = TYPE_MAX_VALUE (sizetype);
- if (cxx_dialect >= cxx11)
+ if (cxx_dialect >= cxx11 && flag_exceptions)
errval = throw_bad_array_new_length ();
if (outer_nelts_check != NULL_TREE)
size = fold_build3 (COND_EXPR, sizetype, outer_nelts_check,
is big enough for all the initializers. */
if (init && TREE_CODE (init) == CONSTRUCTOR
&& CONSTRUCTOR_NELTS (init) > 0
- && !TREE_CONSTANT (maxindex))
+ && !TREE_CONSTANT (maxindex)
+ && flag_exceptions)
length_check = fold_build2 (LT_EXPR, boolean_type_node, maxindex,
size_int (CONSTRUCTOR_NELTS (init) - 1));
brace-enclosed initializers. In this case, digest_init and
store_constructor will handle the semantics for us. */
+ if (BRACE_ENCLOSED_INITIALIZER_P (init))
+ init = digest_init (atype, init, complain);
stmt_expr = build2 (INIT_EXPR, atype, base, init);
if (length_check)
stmt_expr = build3 (COND_EXPR, atype, length_check,