On 10/26/2015 10:06 PM, Martin Sebor wrote:
+ if (TREE_CONSTANT (maybe_constant_value (outer_nelts))) + { + if (tree_int_cst_lt (max_outer_nelts_tree, outer_nelts))
maybe_constant_value may return a constant, but that doesn't mean that outer_nelts was already constant; if it wasn't, the call to tree_int_cst_lt will fail.
+ tree nelts_save = nelts; + nelts = maybe_constant_value (nelts); + + if (!TREE_CONSTANT (nelts)) + nelts = nelts_save; + + /* The expression in a noptr-new-declarator is erroneous if it's of + non-class type and its value before converting to std::size_t is + less than zero. ... If the expression is a constant expression, + the program is ill-fomed. */ + if (TREE_CONSTANT (nelts) && tree_int_cst_sgn (nelts) == -1) + { + if (complain & tf_error) + error ("size of array is negative"); + return error_mark_node; + }
Since we're moving toward delayed folding, I'd prefer to use the result of maybe_constant_value only for this diagnostic, and then continue to pass the unfolded value along.
Jason