From 21318741bb4f00d87f558a2f11d462fa61381e80 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Thu, 2 Mar 2000 18:29:56 +0000 Subject: [PATCH] c-common.c (c_common_nodes_and_builtins): Make sizetype_endlink reference the language-equivalent of sizetype. * c-common.c (c_common_nodes_and_builtins): Make sizetype_endlink reference the language-equivalent of sizetype. * c-typeck.c (comptypes): Treat sizetype like its language equivalent. * fold-const.c (size_binop, size_diffop): Put back checks. * gcse.c (dump_hash_table): Fix minor error in last change. * stor-layout.c (set_sizetype): Set TYPE_DOMAIN of sizetype. Clear TYPE_{NEXT,MAIN}_VARIANT and TYPE_{POINTER,REFERENCE}_to of all sizetypes. * cp/typeck.c (comptypes): Treat sizetype like its language equivalent. From-SVN: r32291 --- gcc/ChangeLog | 11 +++++++++++ gcc/c-common.c | 2 +- gcc/c-typeck.c | 10 ++++++++++ gcc/cp/ChangeLog | 4 ++++ gcc/cp/typeck.c | 20 +++++++++----------- gcc/fold-const.c | 8 ++++---- gcc/gcse.c | 13 +++++++------ gcc/stor-layout.c | 10 +++++++++- 8 files changed, 55 insertions(+), 23 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 248c1f5a6a9..0d08e6b6971 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +Thu Mar 2 13:29:46 2000 Richard Kenner + + * c-common.c (c_common_nodes_and_builtins): Make sizetype_endlink + reference the language-equivalent of sizetype. + * c-typeck.c (comptypes): Treat sizetype like its language equivalent. + * fold-const.c (size_binop, size_diffop): Put back checks. + * gcse.c (dump_hash_table): Fix minor error in last change. + * stor-layout.c (set_sizetype): Set TYPE_DOMAIN of sizetype. + Clear TYPE_{NEXT,MAIN}_VARIANT and TYPE_{POINTER,REFERENCE}_to of + all sizetypes. + Thu Mar 2 12:48:45 MET 2000 Jan Hubicka * calls.c (expand_call) Do not attempt to combine stack adjustments diff --git a/gcc/c-common.c b/gcc/c-common.c index 0a7db5c78f0..262022fb4e2 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3547,7 +3547,7 @@ c_common_nodes_and_builtins (cplus_mode, no_builtins, no_nonansi_builtins) ptr_ftype = build_function_type (ptr_type_node, NULL_TREE); ptr_ftype_unsigned = build_function_type (ptr_type_node, unsigned_endlink); - sizetype_endlink = tree_cons (NULL_TREE, sizetype, endlink); + sizetype_endlink = tree_cons (NULL_TREE, TYPE_DOMAIN (sizetype), endlink); /* We realloc here because sizetype could be int or unsigned. S'ok. */ ptr_ftype_sizetype = build_function_type (ptr_type_node, sizetype_endlink); diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 01446f2b859..6d85c359280 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -436,6 +436,16 @@ comptypes (type1, type2) || TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK) return 1; + /* If either type is the internal version of sizetype, return the + language version. */ + if (TREE_CODE (t1) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t1) + && TYPE_DOMAIN (t1) != 0) + t1 = TYPE_DOMAIN (t1); + + if (TREE_CODE (t2) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t2) + && TYPE_DOMAIN (t2) != 0) + t2 = TYPE_DOMAIN (t2); + /* Treat an enum type as the integer type of the same width and signedness. */ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e42c76474c8..d7e697afbf1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +Thu Mar 2 13:32:01 2000 Richard Kenner + + * typeck.c (comptypes): Treat sizetype like its language equivalent. + 2000-03-01 Bernd Schmidt * typeck.c (maybe_warn_about_returning_address_of_local): Reorganize diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index dd246afd825..8fc3ab8a667 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -934,17 +934,15 @@ comptypes (t1, t2, strict) if (t2 == error_mark_node) return 0; - /* If this is a strict comparison with a sizetype, the actual types - won't be the same (since we need to set TYPE_IS_SIZETYPE, so verify - if they are both the same size and signedness. */ - if (strict == COMPARE_STRICT - && TREE_CODE (t2) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t2) - && TREE_CODE (t1) == INTEGER_TYPE - && TREE_UNSIGNED (t1) == TREE_UNSIGNED (t2) - && TYPE_MODE (t1) == TYPE_MODE (t2) - && TYPE_MIN_VALUE (t1) == TYPE_MIN_VALUE (t2) - && TYPE_MAX_VALUE (t1) == TYPE_MAX_VALUE (t2)) - return 1; + /* If either type is the internal version of sizetype, return the + language version. */ + if (TREE_CODE (t1) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t1) + && TYPE_DOMAIN (t1) != 0) + t1 = TYPE_DOMAIN (t1); + + if (TREE_CODE (t2) == INTEGER_TYPE && TYPE_IS_SIZETYPE (t2) + && TYPE_DOMAIN (t2) != 0) + t2 = TYPE_DOMAIN (t2); if (strict & COMPARE_RELAXED) { diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 097650f46ec..7a4a48566bc 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1868,8 +1868,8 @@ size_binop (code, arg0, arg1) { tree type = TREE_TYPE (arg0); - if (TREE_CODE (type) != INTEGER_TYPE - || TREE_CODE (TREE_TYPE (arg1)) != INTEGER_TYPE) + if (TREE_CODE (type) != INTEGER_TYPE || ! TYPE_IS_SIZETYPE (type) + || type != TREE_TYPE (arg1)) abort (); /* Handle the special case of two integer constants faster. */ @@ -1905,8 +1905,8 @@ size_diffop (arg0, arg1) tree type = TREE_TYPE (arg0); tree ctype; - if (TREE_CODE (type) != INTEGER_TYPE - || TREE_CODE (TREE_TYPE (arg1)) != INTEGER_TYPE) + if (TREE_CODE (type) != INTEGER_TYPE || ! TYPE_IS_SIZETYPE (type) + || type != TREE_TYPE (arg1)) abort (); /* If the type is already signed, just do the simple thing. */ diff --git a/gcc/gcse.c b/gcc/gcse.c index 21829e710c7..1ac98296e4f 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -2009,12 +2009,13 @@ dump_hash_table (file, name, table, table_size, total_size) name, table_size, total_size); for (i = 0; i < total_size; i++) - { - fprintf (file, "Index %d (hash value %d)\n ", - expr->bitmap_index, hash_val[i]); - print_rtl (file, flat_table[i]->expr); - fprintf (file, "\n"); - } + if (flat_table[i] != 0) + { + fprintf (file, "Index %d (hash value %d)\n ", + expr->bitmap_index, hash_val[i]); + print_rtl (file, flat_table[i]->expr); + fprintf (file, "\n"); + } fprintf (file, "\n"); diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index c1187b742e9..ab925694e31 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -1402,6 +1402,7 @@ set_sizetype (type) /* Make copies of nodes since we'll be setting TYPE_IS_SIZETYPE. */ sizetype = copy_node (type); + TYPE_DOMAIN (sizetype) = type; bitsizetype = make_node (INTEGER_TYPE); TYPE_NAME (bitsizetype) = TYPE_NAME (type); TYPE_PRECISION (bitsizetype) = precision; @@ -1430,8 +1431,15 @@ set_sizetype (type) TYPE_NAME (bitsizetype) = get_identifier ("bit_size_type"); + /* Show is a sizetype, is a main type, and has no pointers to it. */ for (i = 0; i < sizeof sizetype_tab / sizeof sizetype_tab[0]; i++) - TYPE_IS_SIZETYPE (sizetype_tab[i]) = 1; + { + TYPE_IS_SIZETYPE (sizetype_tab[i]) = 1; + TYPE_MAIN_VARIANT (sizetype_tab[i]) = sizetype_tab[i]; + TYPE_NEXT_VARIANT (sizetype_tab[i]) = 0; + TYPE_POINTER_TO (sizetype_tab[i]) = 0; + TYPE_REFERENCE_TO (sizetype_tab[i]) = 0; + } ggc_add_tree_root ((tree *) &sizetype_tab, sizeof sizetype_tab / sizeof (tree));