On 1/29/19 7:15 PM, Martin Sebor wrote:
+ /* Try to convert the original SIZE to a ssizetype. */
+ if (orig_size != error_mark_node
+ && !TYPE_UNSIGNED (TREE_TYPE (orig_size)))
+ {
+ if (TREE_CODE (size) == INTEGER_CST
+ && tree_int_cst_sign_bit (size))
+ diagsize = build_converted_constant_expr (ssizetype, size,
+ tsubst_flags_t ());
+ else if (size == error_mark_node
+ && TREE_CODE (orig_size) == INTEGER_CST
+ && tree_int_cst_sign_bit (orig_size))
+ diagsize = build_converted_constant_expr (ssizetype, orig_size,
+ tsubst_flags_t ());
+ }
Using build_converted_constant_expr here looks odd; that's a
language-level notion, and we're dealing with compiler internals.
fold_convert seems more appropriate.
+ if (TREE_CONSTANT (size))
+ {
+ if (!diagsize && TREE_CODE (size) == INTEGER_CST)
+ diagsize = size;
+ }
+ else
size = osize;
}
@@ -9732,15 +9758,12 @@ compute_array_index_type_loc (location_t name_loc,
if (TREE_CODE (size) == INTEGER_CST)
{
/* An array must have a positive number of elements. */
- if (!valid_constant_size_p (size))
+ if (!diagsize)
+ diagsize = size;
It seems like the earlier hunk here is unnecessary; if size is an
INTEGER_CST, it will be unchanged, and so be used for diagsize in the
latter hunk without any changes to the earlier location. Actually, why
not do all of the diagsize logic down here? There doesn't seem to be
anything above that relies on information we will have lost at this point.
Jason