tree
build_vector_from_ctor (tree type, vec<constructor_elt, va_gc> *v)
{
+ if (vec_safe_length (v) == 0)
+ return build_zero_cst (type);
+
unsigned HOST_WIDE_INT idx, nelts;
tree value;
uint64_type_node = make_or_reuse_type (64, 1);
/* Decimal float types. */
- dfloat32_type_node = make_node (REAL_TYPE);
- TYPE_PRECISION (dfloat32_type_node) = DECIMAL32_TYPE_SIZE;
- SET_TYPE_MODE (dfloat32_type_node, SDmode);
- layout_type (dfloat32_type_node);
- dfloat32_ptr_type_node = build_pointer_type (dfloat32_type_node);
-
- dfloat64_type_node = make_node (REAL_TYPE);
- TYPE_PRECISION (dfloat64_type_node) = DECIMAL64_TYPE_SIZE;
- SET_TYPE_MODE (dfloat64_type_node, DDmode);
- layout_type (dfloat64_type_node);
- dfloat64_ptr_type_node = build_pointer_type (dfloat64_type_node);
-
- dfloat128_type_node = make_node (REAL_TYPE);
- TYPE_PRECISION (dfloat128_type_node) = DECIMAL128_TYPE_SIZE;
- SET_TYPE_MODE (dfloat128_type_node, TDmode);
- layout_type (dfloat128_type_node);
- dfloat128_ptr_type_node = build_pointer_type (dfloat128_type_node);
+ if (targetm.decimal_float_supported_p ())
+ {
+ dfloat32_type_node = make_node (REAL_TYPE);
+ TYPE_PRECISION (dfloat32_type_node) = DECIMAL32_TYPE_SIZE;
+ SET_TYPE_MODE (dfloat32_type_node, SDmode);
+ layout_type (dfloat32_type_node);
+
+ dfloat64_type_node = make_node (REAL_TYPE);
+ TYPE_PRECISION (dfloat64_type_node) = DECIMAL64_TYPE_SIZE;
+ SET_TYPE_MODE (dfloat64_type_node, DDmode);
+ layout_type (dfloat64_type_node);
+
+ dfloat128_type_node = make_node (REAL_TYPE);
+ TYPE_PRECISION (dfloat128_type_node) = DECIMAL128_TYPE_SIZE;
+ SET_TYPE_MODE (dfloat128_type_node, TDmode);
+ layout_type (dfloat128_type_node);
+ }
complex_integer_type_node = build_complex_type (integer_type_node, true);
complex_float_type_node = build_complex_type (float_type_node, true);
static tree
build_truth_vector_type_for (tree vectype)
{
+ machine_mode vector_mode = TYPE_MODE (vectype);
poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype);
- poly_uint64 vector_size = tree_to_poly_uint64 (TYPE_SIZE_UNIT (vectype));
machine_mode mask_mode;
- if (targetm.vectorize.get_mask_mode (nunits,
- vector_size).exists (&mask_mode))
+ if (VECTOR_MODE_P (vector_mode)
+ && targetm.vectorize.get_mask_mode (vector_mode).exists (&mask_mode))
return build_truth_vector_type_for_mode (nunits, mask_mode);
- poly_uint64 vsize = vector_size * BITS_PER_UNIT;
+ poly_uint64 vsize = tree_to_poly_uint64 (TYPE_SIZE (vectype));
unsigned HOST_WIDE_INT esize = vector_element_size (vsize, nunits);
tree bool_type = build_nonstandard_boolean_type (esize);
return default_is_empty_type (TYPE_MAIN_VARIANT (type));
}
+/* Determine whether TYPE is a structure with a flexible array member,
+ or a union containing such a structure (possibly recursively). */
+
+bool
+flexible_array_type_p (const_tree type)
+{
+ tree x, last;
+ switch (TREE_CODE (type))
+ {
+ case RECORD_TYPE:
+ last = NULL_TREE;
+ for (x = TYPE_FIELDS (type); x != NULL_TREE; x = DECL_CHAIN (x))
+ if (TREE_CODE (x) == FIELD_DECL)
+ last = x;
+ if (last == NULL_TREE)
+ return false;
+ if (TREE_CODE (TREE_TYPE (last)) == ARRAY_TYPE
+ && TYPE_SIZE (TREE_TYPE (last)) == NULL_TREE
+ && TYPE_DOMAIN (TREE_TYPE (last)) != NULL_TREE
+ && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (last))) == NULL_TREE)
+ return true;
+ return false;
+ case UNION_TYPE:
+ for (x = TYPE_FIELDS (type); x != NULL_TREE; x = DECL_CHAIN (x))
+ {
+ if (TREE_CODE (x) == FIELD_DECL
+ && flexible_array_type_p (TREE_TYPE (x)))
+ return true;
+ }
+ return false;
+ default:
+ return false;
+ }
+}
+
/* Like int_size_in_bytes, but handle empty records specially. */
HOST_WIDE_INT
return TYPE_MAX_VALUE (ptrdiff_type_node);
}
+/* A wrapper around TARGET_VERIFY_TYPE_CONTEXT that makes the silent_p
+ parameter default to false and that weeds out error_mark_node. */
+
+bool
+verify_type_context (location_t loc, type_context_kind context,
+ const_tree type, bool silent_p)
+{
+ if (type == error_mark_node)
+ return true;
+
+ gcc_assert (TYPE_P (type));
+ return (!targetm.verify_type_context
+ || targetm.verify_type_context (loc, context, type, silent_p));
+}
+
#if CHECKING_P
namespace selftest {