aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2005-11-09 23:13:08 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2005-11-09 23:13:08 +0000
commit7e854c00d04f2279ac12fe76bcd9d62f0e800223 (patch)
tree00f17cd91db2a763b171f4ef68a7c278f4adde9e /gcc/tree.c
parent378e957760be0bd9d27e6d4121c9ed49b0295138 (diff)
downloadgcc-7e854c00d04f2279ac12fe76bcd9d62f0e800223.zip
gcc-7e854c00d04f2279ac12fe76bcd9d62f0e800223.tar.gz
gcc-7e854c00d04f2279ac12fe76bcd9d62f0e800223.tar.bz2
tree.c (build_qualified_type): Chain the new type to the original type's TYPE_NEXT_PTR_TO or TYPE_NEXT_REF_TO...
* tree.c (build_qualified_type): Chain the new type to the original type's TYPE_NEXT_PTR_TO or TYPE_NEXT_REF_TO linked lists if it is a POINTER_TYPE or a REFERENCE_TYPE respectively. (build_pointer_type_for_mode): Only return unqualified types. (build_reference_type_for_mode): Likewise. From-SVN: r106716
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index ccd6cf5..4edccd5 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3702,6 +3702,20 @@ build_qualified_type (tree type, int type_quals)
{
t = build_variant_type_copy (type);
set_type_quals (t, type_quals);
+
+ /* If it's a pointer type, the new variant points to the same type. */
+ if (TREE_CODE (type) == POINTER_TYPE)
+ {
+ TYPE_NEXT_PTR_TO (t) = TYPE_NEXT_PTR_TO (type);
+ TYPE_NEXT_PTR_TO (type) = t;
+ }
+
+ /* Same for a reference type. */
+ else if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ TYPE_NEXT_REF_TO (t) = TYPE_NEXT_REF_TO (type);
+ TYPE_NEXT_REF_TO (type) = t;
+ }
}
return t;
@@ -4817,10 +4831,12 @@ build_pointer_type_for_mode (tree to_type, enum machine_mode mode,
&& TREE_CODE (TYPE_POINTER_TO (to_type)) != POINTER_TYPE)
return TYPE_POINTER_TO (to_type);
- /* First, if we already have a type for pointers to TO_TYPE and it's
- the proper mode, use it. */
+ /* First, if we already have an unqualified type for pointers to TO_TYPE
+ and it's the proper mode, use it. */
for (t = TYPE_POINTER_TO (to_type); t; t = TYPE_NEXT_PTR_TO (t))
- if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
+ if (TYPE_MODE (t) == mode
+ && !TYPE_QUALS (t)
+ && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
return t;
t = make_node (POINTER_TYPE);
@@ -4866,10 +4882,12 @@ build_reference_type_for_mode (tree to_type, enum machine_mode mode,
&& TREE_CODE (TYPE_REFERENCE_TO (to_type)) != REFERENCE_TYPE)
return TYPE_REFERENCE_TO (to_type);
- /* First, if we already have a type for pointers to TO_TYPE and it's
- the proper mode, use it. */
+ /* First, if we already have an unqualified type for references to TO_TYPE
+ and it's the proper mode, use it. */
for (t = TYPE_REFERENCE_TO (to_type); t; t = TYPE_NEXT_REF_TO (t))
- if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
+ if (TYPE_MODE (t) == mode
+ && !TYPE_QUALS (t)
+ && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
return t;
t = make_node (REFERENCE_TYPE);