aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/gcc-interface')
-rw-r--r--gcc/ada/gcc-interface/decl.c12
-rw-r--r--gcc/ada/gcc-interface/gigi.h3
-rw-r--r--gcc/ada/gcc-interface/misc.c21
-rw-r--r--gcc/ada/gcc-interface/utils.c52
4 files changed, 48 insertions, 40 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index c9ca2a6..0669875 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -2070,7 +2070,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* Now build the array type. */
for (index = ndim - 1; index >= 0; index--)
{
- tem = build_array_type (tem, gnu_index_types[index]);
+ tem = build_nonshared_array_type (tem, gnu_index_types[index]);
TYPE_MULTI_ARRAY_P (tem) = (index > 0);
if (array_type_has_nonaliased_component (tem, gnat_entity))
TYPE_NONALIASED_COMPONENT (tem) = 1;
@@ -2403,7 +2403,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* Now build the array type. */
for (index = ndim - 1; index >= 0; index --)
{
- gnu_type = build_array_type (gnu_type, gnu_index_types[index]);
+ gnu_type = build_nonshared_array_type (gnu_type,
+ gnu_index_types[index]);
TYPE_MULTI_ARRAY_P (gnu_type) = (index > 0);
if (array_type_has_nonaliased_component (gnu_type, gnat_entity))
TYPE_NONALIASED_COMPONENT (gnu_type) = 1;
@@ -2649,8 +2650,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
gnat_entity);
gnu_type
- = build_array_type (gnat_to_gnu_type (Component_Type (gnat_entity)),
- gnu_index_type);
+ = build_nonshared_array_type (gnat_to_gnu_type
+ (Component_Type (gnat_entity)),
+ gnu_index_type);
if (array_type_has_nonaliased_component (gnu_type, gnat_entity))
TYPE_NONALIASED_COMPONENT (gnu_type) = 1;
relate_alias_sets (gnu_type, gnu_string_type, ALIAS_SET_COPY);
@@ -8610,7 +8612,7 @@ substitute_in_type (tree t, tree f, tree r)
if (component == TREE_TYPE (t) && domain == TYPE_DOMAIN (t))
return t;
- nt = build_array_type (component, domain);
+ nt = build_nonshared_array_type (component, domain);
TYPE_ALIGN (nt) = TYPE_ALIGN (t);
TYPE_USER_ALIGN (nt) = TYPE_USER_ALIGN (t);
SET_TYPE_MODE (nt, TYPE_MODE (t));
diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index b464cac..dd30b24 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -447,6 +447,9 @@ extern tree gnat_signed_type (tree type_node);
transparently converted to each other. */
extern int gnat_types_compatible_p (tree t1, tree t2);
+/* Return true if T, a FUNCTION_TYPE, has the specified list of flags. */
+extern bool fntype_same_flags_p (const_tree, tree, bool, bool, bool);
+
/* Create an expression whose value is that of EXPR,
converted to type TYPE. The TREE_TYPE of the value
is always TYPE. This function implements all reasonable
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index 080e988..1167f03 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -72,6 +72,7 @@ static void gnat_print_decl (FILE *, tree, int);
static void gnat_print_type (FILE *, tree, int);
static const char *gnat_printable_name (tree, int);
static const char *gnat_dwarf_name (tree, int);
+static bool gnat_type_hash_eq (const_tree, const_tree);
static tree gnat_return_tree (tree);
static void gnat_parse_file (int);
static void internal_error_function (diagnostic_context *,
@@ -98,8 +99,8 @@ static tree gnat_eh_personality (void);
#define LANG_HOOKS_POST_OPTIONS gnat_post_options
#undef LANG_HOOKS_PARSE_FILE
#define LANG_HOOKS_PARSE_FILE gnat_parse_file
-#undef LANG_HOOKS_HASH_TYPES
-#define LANG_HOOKS_HASH_TYPES false
+#undef LANG_HOOKS_TYPE_HASH_EQ
+#define LANG_HOOKS_TYPE_HASH_EQ gnat_type_hash_eq
#undef LANG_HOOKS_GETDECLS
#define LANG_HOOKS_GETDECLS lhd_return_null_tree_v
#undef LANG_HOOKS_PUSHDECL
@@ -304,7 +305,7 @@ gnat_init_options (unsigned int decoded_options_count,
/* Post-switch processing. */
-bool
+static bool
gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
{
/* Excess precision other than "fast" requires front-end
@@ -595,6 +596,20 @@ gnat_dwarf_name (tree decl, int verbosity ATTRIBUTE_UNUSED)
return (const char *) IDENTIFIER_POINTER (DECL_NAME (decl));
}
+/* Return true if types T1 and T2 are identical for type hashing purposes.
+ Called only after doing all language independent checks. At present,
+ this function is only called when both types are FUNCTION_TYPE. */
+
+static bool
+gnat_type_hash_eq (const_tree t1, const_tree t2)
+{
+ gcc_assert (TREE_CODE (t1) == FUNCTION_TYPE);
+ return fntype_same_flags_p (t1, TYPE_CI_CO_LIST (t2),
+ TYPE_RETURN_UNCONSTRAINED_P (t2),
+ TYPE_RETURN_BY_DIRECT_REF_P (t2),
+ TREE_ADDRESSABLE (t2));
+}
+
/* Do nothing (return the tree node passed). */
static tree
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index e1f7aab..3fab92b 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -1106,10 +1106,8 @@ create_subprog_type (tree return_type, tree param_decl_list, tree cico_list,
/* TYPE may have been shared since GCC hashes types. If it has a different
CICO_LIST, make a copy. Likewise for the various flags. */
- if (TYPE_CI_CO_LIST (type) != cico_list
- || TYPE_RETURN_UNCONSTRAINED_P (type) != return_unconstrained_p
- || TYPE_RETURN_BY_DIRECT_REF_P (type) != return_by_direct_ref_p
- || TREE_ADDRESSABLE (type) != return_by_invisi_ref_p)
+ if (!fntype_same_flags_p (type, cico_list, return_unconstrained_p,
+ return_by_direct_ref_p, return_by_invisi_ref_p))
{
type = copy_type (type);
TYPE_CI_CO_LIST (type) = cico_list;
@@ -1165,17 +1163,9 @@ tree
create_index_type (tree min, tree max, tree index, Node_Id gnat_node)
{
/* First build a type for the desired range. */
- tree type = build_range_type (sizetype, min, max);
-
- /* If this type has the TYPE_INDEX_TYPE we want, return it. */
- if (TYPE_INDEX_TYPE (type) == index)
- return type;
-
- /* Otherwise, if TYPE_INDEX_TYPE is set, make a copy. Note that we have
- no way of sharing these types, but that's only a small hole. */
- if (TYPE_INDEX_TYPE (type))
- type = copy_type (type);
+ tree type = build_nonshared_range_type (sizetype, min, max);
+ /* Then set the index type. */
SET_TYPE_INDEX_TYPE (type, index);
create_type_decl (NULL_TREE, type, NULL, true, false, gnat_node);
@@ -1194,26 +1184,12 @@ create_range_type (tree type, tree min, tree max)
type = sizetype;
/* First build a type with the base range. */
- range_type
- = build_range_type (type, TYPE_MIN_VALUE (type), TYPE_MAX_VALUE (type));
-
- min = convert (type, min);
- max = convert (type, max);
-
- /* If this type has the TYPE_RM_{MIN,MAX}_VALUE we want, return it. */
- if (TYPE_RM_MIN_VALUE (range_type)
- && TYPE_RM_MAX_VALUE (range_type)
- && operand_equal_p (TYPE_RM_MIN_VALUE (range_type), min, 0)
- && operand_equal_p (TYPE_RM_MAX_VALUE (range_type), max, 0))
- return range_type;
-
- /* Otherwise, if TYPE_RM_{MIN,MAX}_VALUE is set, make a copy. */
- if (TYPE_RM_MIN_VALUE (range_type) || TYPE_RM_MAX_VALUE (range_type))
- range_type = copy_type (range_type);
+ range_type = build_nonshared_range_type (type, TYPE_MIN_VALUE (type),
+ TYPE_MAX_VALUE (type));
/* Then set the actual range. */
- SET_TYPE_RM_MIN_VALUE (range_type, min);
- SET_TYPE_RM_MAX_VALUE (range_type, max);
+ SET_TYPE_RM_MIN_VALUE (range_type, convert (type, min));
+ SET_TYPE_RM_MAX_VALUE (range_type, convert (type, max));
return range_type;
}
@@ -2121,6 +2097,18 @@ gnat_types_compatible_p (tree t1, tree t2)
return 0;
}
+
+/* Return true if T, a FUNCTION_TYPE, has the specified list of flags. */
+
+bool
+fntype_same_flags_p (const_tree t, tree cico_list, bool return_unconstrained_p,
+ bool return_by_direct_ref_p, bool return_by_invisi_ref_p)
+{
+ return TYPE_CI_CO_LIST (t) == cico_list
+ && TYPE_RETURN_UNCONSTRAINED_P (t) == return_unconstrained_p
+ && TYPE_RETURN_BY_DIRECT_REF_P (t) == return_by_direct_ref_p
+ && TREE_ADDRESSABLE (t) == return_by_invisi_ref_p;
+}
/* EXP is an expression for the size of an object. If this size contains
discriminant references, replace them with the maximum (if MAX_P) or