tree global_trees[TI_MAX];
tree integer_types[itk_none];
-unsigned char tree_contains_struct[256][64];
+unsigned char tree_contains_struct[MAX_TREE_CODES][64];
/* Number of operands for each OpenMP clause. */
unsigned const char omp_clause_num_ops[] =
gcc_assert (code != GIMPLE_MODIFY_STMT);
#endif
+ if ((code == MINUS_EXPR || code == PLUS_EXPR || code == MULT_EXPR)
+ && arg0 && arg1 && tt && POINTER_TYPE_P (tt))
+ gcc_assert (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST);
+
+ if (code == POINTER_PLUS_EXPR && arg0 && arg1 && tt)
+ gcc_assert (POINTER_TYPE_P (tt) && POINTER_TYPE_P (TREE_TYPE (arg0))
+ && TREE_CODE (TREE_TYPE (arg1)) == INTEGER_TYPE
+ && useless_type_conversion_p (sizetype, TREE_TYPE (arg1)));
+
t = make_node_stat (code PASS_MEM_STAT);
TREE_TYPE (t) = tt;
t = make_node_stat (code PASS_MEM_STAT);
TREE_TYPE (t) = tt;
- side_effects = TREE_SIDE_EFFECTS (t);
+ /* As a special exception, if COND_EXPR has NULL branches, we
+ assume that it is a gimple statement and always consider
+ it to have side effects. */
+ if (code == COND_EXPR
+ && tt == void_type_node
+ && arg1 == NULL_TREE
+ && arg2 == NULL_TREE)
+ side_effects = true;
+ else
+ side_effects = TREE_SIDE_EFFECTS (t);
PROCESS_ARG(0);
PROCESS_ARG(1);
*no_add_attrs = true;
return tree_cons (name, args, NULL_TREE);
}
- if (TREE_CODE (node) != RECORD_TYPE && TREE_CODE (node) != UNION_TYPE)
+ if (TREE_CODE (node) == RECORD_TYPE
+ || TREE_CODE (node) == UNION_TYPE)
+ {
+ node = TYPE_NAME (node);
+ if (!node)
+ return NULL_TREE;
+ }
+ else
{
warning (OPT_Wattributes, "%qs attribute ignored",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
+ return NULL_TREE;
}
-
- return NULL_TREE;
}
if (TREE_CODE (node) != FUNCTION_DECL
- && TREE_CODE (node) != VAR_DECL)
+ && TREE_CODE (node) != VAR_DECL
+ && TREE_CODE (node) != TYPE_DECL)
{
*no_add_attrs = true;
warning (OPT_Wattributes, "%qs attribute ignored",
*no_add_attrs = true;
}
+ /* A dllexport'd entity must have default visibility so that other
+ program units (shared libraries or the main executable) can see
+ it. A dllimport'd entity must have default visibility so that
+ the linker knows that undefined references within this program
+ unit can be resolved by the dynamic linker. */
+ if (!*no_add_attrs)
+ {
+ if (DECL_VISIBILITY_SPECIFIED (node)
+ && DECL_VISIBILITY (node) != VISIBILITY_DEFAULT)
+ error ("%qs implies default visibility, but %qD has already "
+ "been declared with a different visibility",
+ IDENTIFIER_POINTER (name), node);
+ DECL_VISIBILITY (node) = VISIBILITY_DEFAULT;
+ DECL_VISIBILITY_SPECIFIED (node) = 1;
+ }
+
return NULL_TREE;
}
/* Make it its own variant. */
TYPE_MAIN_VARIANT (t) = t;
TYPE_NEXT_VARIANT (t) = 0;
-
+
+ /* Note that it is now possible for TYPE_MIN_VALUE to be a value
+ whose TREE_TYPE is not t. This can also happen in the Ada
+ frontend when using subtypes. */
+
return t;
}
return type;
}
+/* Computes the canonical argument types from the argument type list
+ ARGTYPES.
+
+ Upon return, *ANY_STRUCTURAL_P will be true iff either it was true
+ on entry to this function, or if any of the ARGTYPES are
+ structural.
+
+ Upon return, *ANY_NONCANONICAL_P will be true iff either it was
+ true on entry to this function, or if any of the ARGTYPES are
+ non-canonical.
+
+ Returns a canonical argument list, which may be ARGTYPES when the
+ canonical argument list is unneeded (i.e., *ANY_STRUCTURAL_P is
+ true) or would not differ from ARGTYPES. */
+
+static tree
+maybe_canonicalize_argtypes(tree argtypes,
+ bool *any_structural_p,
+ bool *any_noncanonical_p)
+{
+ tree arg;
+ bool any_noncanonical_argtypes_p = false;
+
+ for (arg = argtypes; arg && !(*any_structural_p); arg = TREE_CHAIN (arg))
+ {
+ if (!TREE_VALUE (arg) || TREE_VALUE (arg) == error_mark_node)
+ /* Fail gracefully by stating that the type is structural. */
+ *any_structural_p = true;
+ else if (TYPE_STRUCTURAL_EQUALITY_P (TREE_VALUE (arg)))
+ *any_structural_p = true;
+ else if (TYPE_CANONICAL (TREE_VALUE (arg)) != TREE_VALUE (arg)
+ || TREE_PURPOSE (arg))
+ /* If the argument has a default argument, we consider it
+ non-canonical even though the type itself is canonical.
+ That way, different variants of function and method types
+ with default arguments will all point to the variant with
+ no defaults as their canonical type. */
+ any_noncanonical_argtypes_p = true;
+ }
+
+ if (*any_structural_p)
+ return argtypes;
+
+ if (any_noncanonical_argtypes_p)
+ {
+ /* Build the canonical list of argument types. */
+ tree canon_argtypes = NULL_TREE;
+ bool is_void = false;
+
+ for (arg = argtypes; arg; arg = TREE_CHAIN (arg))
+ {
+ if (arg == void_list_node)
+ is_void = true;
+ else
+ canon_argtypes = tree_cons (NULL_TREE,
+ TYPE_CANONICAL (TREE_VALUE (arg)),
+ canon_argtypes);
+ }
+
+ canon_argtypes = nreverse (canon_argtypes);
+ if (is_void)
+ canon_argtypes = chainon (canon_argtypes, void_list_node);
+
+ /* There is a non-canonical type. */
+ *any_noncanonical_p = true;
+ return canon_argtypes;
+ }
+
+ /* The canonical argument types are the same as ARGTYPES. */
+ return argtypes;
+}
+
/* Construct, lay out and return
the type of functions returning type VALUE_TYPE
given arguments of types ARG_TYPES.
{
tree t;
hashval_t hashcode = 0;
+ bool any_structural_p, any_noncanonical_p;
+ tree canon_argtypes;
if (TREE_CODE (value_type) == FUNCTION_TYPE)
{
TREE_TYPE (t) = value_type;
TYPE_ARG_TYPES (t) = arg_types;
- /* We don't have canonicalization of function types, yet. */
- SET_TYPE_STRUCTURAL_EQUALITY (t);
-
/* If we already have such a type, use the old one. */
hashcode = iterative_hash_object (TYPE_HASH (value_type), hashcode);
hashcode = type_hash_list (arg_types, hashcode);
t = type_hash_canon (hashcode, t);
+ /* Set up the canonical type. */
+ any_structural_p = TYPE_STRUCTURAL_EQUALITY_P (value_type);
+ any_noncanonical_p = TYPE_CANONICAL (value_type) != value_type;
+ canon_argtypes = maybe_canonicalize_argtypes (arg_types,
+ &any_structural_p,
+ &any_noncanonical_p);
+ if (any_structural_p)
+ SET_TYPE_STRUCTURAL_EQUALITY (t);
+ else if (any_noncanonical_p)
+ TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
+ canon_argtypes);
+
if (!COMPLETE_TYPE_P (t))
layout_type (t);
return t;
tree t;
tree ptype;
int hashcode = 0;
+ bool any_structural_p, any_noncanonical_p;
+ tree canon_argtypes;
/* Make a node of the sort we want. */
t = make_node (METHOD_TYPE);
argtypes = tree_cons (NULL_TREE, ptype, argtypes);
TYPE_ARG_TYPES (t) = argtypes;
- /* We don't have canonicalization of method types yet. */
- SET_TYPE_STRUCTURAL_EQUALITY (t);
-
/* If we already have such a type, use the old one. */
hashcode = iterative_hash_object (TYPE_HASH (basetype), hashcode);
hashcode = iterative_hash_object (TYPE_HASH (rettype), hashcode);
hashcode = type_hash_list (argtypes, hashcode);
t = type_hash_canon (hashcode, t);
+ /* Set up the canonical type. */
+ any_structural_p
+ = (TYPE_STRUCTURAL_EQUALITY_P (basetype)
+ || TYPE_STRUCTURAL_EQUALITY_P (rettype));
+ any_noncanonical_p
+ = (TYPE_CANONICAL (basetype) != basetype
+ || TYPE_CANONICAL (rettype) != rettype);
+ canon_argtypes = maybe_canonicalize_argtypes (TREE_CHAIN (argtypes),
+ &any_structural_p,
+ &any_noncanonical_p);
+ if (any_structural_p)
+ SET_TYPE_STRUCTURAL_EQUALITY (t);
+ else if (any_noncanonical_p)
+ TYPE_CANONICAL (t)
+ = build_method_type_directly (TYPE_CANONICAL (basetype),
+ TYPE_CANONICAL (rettype),
+ canon_argtypes);
if (!COMPLETE_TYPE_P (t))
layout_type (t);
name = 0;
if (name != 0)
- TYPE_NAME (t) = get_identifier (name);
+ TYPE_NAME (t) = build_decl (TYPE_DECL, get_identifier (name), t);
}
return build_qualified_type (t, TYPE_QUALS (component_type));
return !fit_double_type (low, high, &low, &high, type);
}
+/* Stores bounds of an integer TYPE in MIN and MAX. If TYPE has non-constant
+ bounds or is a POINTER_TYPE, the maximum and/or minimum values that can be
+ represented (assuming two's-complement arithmetic) within the bit
+ precision of the type are returned instead. */
+
+void
+get_type_static_bounds (tree type, mpz_t min, mpz_t max)
+{
+ if (!POINTER_TYPE_P (type) && TYPE_MIN_VALUE (type)
+ && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
+ mpz_set_double_int (min, tree_to_double_int (TYPE_MIN_VALUE (type)),
+ TYPE_UNSIGNED (type));
+ else
+ {
+ if (TYPE_UNSIGNED (type))
+ mpz_set_ui (min, 0);
+ else
+ {
+ double_int mn;
+ mn = double_int_mask (TYPE_PRECISION (type) - 1);
+ mn = double_int_sext (double_int_add (mn, double_int_one),
+ TYPE_PRECISION (type));
+ mpz_set_double_int (min, mn, false);
+ }
+ }
+
+ if (!POINTER_TYPE_P (type) && TYPE_MAX_VALUE (type)
+ && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
+ mpz_set_double_int (max, tree_to_double_int (TYPE_MAX_VALUE (type)),
+ TYPE_UNSIGNED (type));
+ else
+ {
+ if (TYPE_UNSIGNED (type))
+ mpz_set_double_int (max, double_int_mask (TYPE_PRECISION (type)),
+ true);
+ else
+ mpz_set_double_int (max, double_int_mask (TYPE_PRECISION (type) - 1),
+ true);
+ }
+}
+
/* Subprogram of following function. Called by walk_tree.
Return *TP if it is an automatic variable or parameter of the
clean_symbol_name (q);
sprintf (q + len, "_%08X_%08X", crc32_string (0, name),
- crc32_string (0, flag_random_seed));
+ crc32_string (0, get_random_seed (false)));
p = q;
}
TYPE_MODE (dfloat128_type_node) = TDmode;
dfloat128_ptr_type_node = build_pointer_type (dfloat128_type_node);
- complex_integer_type_node = make_node (COMPLEX_TYPE);
- TREE_TYPE (complex_integer_type_node) = integer_type_node;
- layout_type (complex_integer_type_node);
-
- complex_float_type_node = make_node (COMPLEX_TYPE);
- TREE_TYPE (complex_float_type_node) = float_type_node;
- layout_type (complex_float_type_node);
-
- complex_double_type_node = make_node (COMPLEX_TYPE);
- TREE_TYPE (complex_double_type_node) = double_type_node;
- layout_type (complex_double_type_node);
-
- complex_long_double_type_node = make_node (COMPLEX_TYPE);
- TREE_TYPE (complex_long_double_type_node) = long_double_type_node;
- layout_type (complex_long_double_type_node);
+ complex_integer_type_node = build_complex_type (integer_type_node);
+ complex_float_type_node = build_complex_type (float_type_node);
+ complex_double_type_node = build_complex_type (double_type_node);
+ complex_long_double_type_node = build_complex_type (long_double_type_node);
{
tree t = targetm.build_builtin_va_list ();
reconstruct_complex_type (tree type, tree bottom)
{
tree inner, outer;
-
- if (POINTER_TYPE_P (type))
+
+ if (TREE_CODE (type) == POINTER_TYPE)
{
inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
- outer = build_pointer_type (inner);
+ outer = build_pointer_type_for_mode (inner, TYPE_MODE (type),
+ TYPE_REF_CAN_ALIAS_ALL (type));
+ }
+ else if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
+ outer = build_reference_type_for_mode (inner, TYPE_MODE (type),
+ TYPE_REF_CAN_ALIAS_ALL (type));
}
else if (TREE_CODE (type) == ARRAY_TYPE)
{
}
else if (TREE_CODE (type) == METHOD_TYPE)
{
- tree argtypes;
inner = reconstruct_complex_type (TREE_TYPE (type), bottom);
/* The build_method_type_directly() routine prepends 'this' to argument list,
so we must compensate by getting rid of it. */
- argtypes = TYPE_ARG_TYPES (type);
- outer = build_method_type_directly (TYPE_METHOD_BASETYPE (type),
- inner,
- TYPE_ARG_TYPES (type));
- TYPE_ARG_TYPES (outer) = argtypes;
+ outer
+ = build_method_type_directly
+ (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (type))),
+ inner,
+ TREE_CHAIN (TYPE_ARG_TYPES (type)));
}
else
return bottom;
return true;
}
-/* Return true if T (assumed to be a DECL) is a global variable. */
-
-bool
-is_global_var (tree t)
-{
- if (MTAG_P (t))
- return (TREE_STATIC (t) || MTAG_GLOBAL (t));
- else
- return (TREE_STATIC (t) || DECL_EXTERNAL (t));
-}
-
/* Return true if T (assumed to be a DECL) must be assigned a memory
location. */
DECL_FIELD_OFFSET (f2), OEP_ONLY_CONST))
return false;
- if (!lang_hooks.types_compatible_p (TREE_TYPE (f1), TREE_TYPE (f2)))
+ if (!types_compatible_p (TREE_TYPE (f1), TREE_TYPE (f2)))
return false;
return true;
return val;
}
+/* If TYPE is an integral type, return an equivalent type which is
+ unsigned iff UNSIGNEDP is true. If TYPE is not an integral type,
+ return TYPE itself. */
+
+tree
+signed_or_unsigned_type_for (int unsignedp, tree type)
+{
+ tree t = type;
+ if (POINTER_TYPE_P (type))
+ t = size_type_node;
+
+ if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp)
+ return t;
+
+ return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp);
+}
/* Returns unsigned variant of TYPE. */
tree
unsigned_type_for (tree type)
{
- if (POINTER_TYPE_P (type))
- return lang_hooks.types.unsigned_type (size_type_node);
- return lang_hooks.types.unsigned_type (type);
+ return signed_or_unsigned_type_for (1, type);
}
/* Returns signed variant of TYPE. */
tree
signed_type_for (tree type)
{
- if (POINTER_TYPE_P (type))
- return lang_hooks.types.signed_type (size_type_node);
- return lang_hooks.types.signed_type (type);
+ return signed_or_unsigned_type_for (0, type);
}
/* Returns the largest value obtainable by casting something in INNER type to