Index: c-common.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-common.c,v retrieving revision 1.572 diff -u -p -r1.572 c-common.c --- c-common.c 10 Sep 2004 15:09:34 -0000 1.572 +++ c-common.c 12 Sep 2004 04:58:48 -0000 @@ -2632,8 +2632,12 @@ c_common_get_alias_set (tree t) tree t1 = c_common_signed_type (t); /* t1 == t can happen for boolean nodes which are always unsigned. */ - if (t1 != t) - return get_alias_set (t1); + if (t1 != t) + { + HOST_WIDE_INT alias_set = get_alias_set (t1); + TYPE_ALIAS_SET (t) = alias_set; + return alias_set; + } } else if (POINTER_TYPE_P (t)) { @@ -2661,10 +2665,15 @@ c_common_get_alias_set (tree t) And, it doesn't make sense for that to be legal unless you can dereference IPP and CIPP. So, we ignore cv-qualifiers on the pointed-to types. This issue has been reported to the - C++ committee. */ - t1 = build_type_no_quals (t); + C++ committee. + Also reference types alias the corresponding pointer type. */ + t1 = build_type_no_quals_pointers_only (t); if (t1 != t) - return get_alias_set (t1); + { + HOST_WIDE_INT alias_set = get_alias_set (t1); + TYPE_ALIAS_SET (t) = alias_set; + return alias_set; + } } /* Handle the case of multiple type nodes referring to "the same" type, Index: tree.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree.c,v retrieving revision 1.425 diff -u -p -r1.425 tree.c --- tree.c 9 Sep 2004 15:58:21 -0000 1.425 +++ tree.c 12 Sep 2004 04:58:49 -0000 @@ -4192,6 +4192,27 @@ build_reference_type (tree to_type) return build_reference_type_for_mode (to_type, ptr_mode, false); } + +/* Build a type that is compatible with t but has no cv quals anywhere + in its type, thus + + const char *const *const * -> char ***. */ + +tree +build_type_no_quals_pointers_only (tree t) +{ + switch (TREE_CODE (t)) + { + case POINTER_TYPE: + case REFERENCE_TYPE: + return build_pointer_type_for_mode (build_type_no_quals_pointers_only (TREE_TYPE (t)), + TYPE_MODE (t), + TYPE_REF_CAN_ALIAS_ALL (t)); + default: + return TYPE_MAIN_VARIANT (t); + } +} + /* Build a type that is compatible with t but has no cv quals anywhere in its type, thus Index: tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree.h,v retrieving revision 1.617 diff -u -p -r1.617 tree.h --- tree.h 10 Sep 2004 19:03:11 -0000 1.617 +++ tree.h 12 Sep 2004 04:58:49 -0000 @@ -2784,6 +2784,7 @@ extern tree build_reference_type (tree); extern tree build_vector_type_for_mode (tree, enum machine_mode); extern tree build_vector_type (tree innertype, int nunits); extern tree build_type_no_quals (tree); +extern tree build_type_no_quals_pointers_only (tree); extern tree build_index_type (tree); extern tree build_index_2_type (tree, tree); extern tree build_array_type (tree, tree);