diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 60efafb3265..69ad2e9d168 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2000-11-13 Andrew Haley + + * tree.c (build_type_no_quals): New function. + * tree.h (build_type_no_quals): Declare. + * c-common.c (c_get_alias_set): When considering type + compatibility for pointer types, ignore cv-qualifiers anywhere in + a pointer chain. + 2000-11-15 Graham Stott * regrename.c (scan_rtx_rtx): Skip to the next chain on diff --git a/gcc/c-common.c b/gcc/c-common.c index e0d8a45a4a5..50620f0ec6a 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -4794,9 +4794,7 @@ lang_get_alias_set (t) 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 = TYPE_MAIN_VARIANT (TREE_TYPE (t)); - t1 = ((TREE_CODE (t) == POINTER_TYPE) - ? build_pointer_type (t1) : build_reference_type (t1)); + t1 = build_type_no_quals (t); if (t1 != t) return get_alias_set (t1); } diff --git a/gcc/tree.c b/gcc/tree.c index 4b3e9300efc..7e820f559ce 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -3798,6 +3798,26 @@ build_reference_type (to_type) return t; } +/* 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 (t) + tree t; +{ + switch (TREE_CODE (t)) + { + case POINTER_TYPE: + return build_pointer_type (build_type_no_quals (TREE_TYPE (t))); + case REFERENCE_TYPE: + return build_reference_type (build_type_no_quals (TREE_TYPE (t))); + default: + return TYPE_MAIN_VARIANT (t); + } +} + /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE. MAXVAL should be the maximum value in the domain (one less than the length of the array). diff --git a/gcc/tree.h b/gcc/tree.h index ed28507af7d..a264df4fbdc 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1923,6 +1923,7 @@ extern tree signed_or_unsigned_type PARAMS ((int, tree)); extern void fixup_unsigned_type PARAMS ((tree)); extern tree build_pointer_type PARAMS ((tree)); extern tree build_reference_type PARAMS ((tree)); +extern tree build_type_no_quals PARAMS ((tree)); extern tree build_index_type PARAMS ((tree)); extern tree build_index_2_type PARAMS ((tree, tree)); extern tree build_array_type PARAMS ((tree, tree));