Index: cp-lang.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v retrieving revision 1.71 diff -c -5 -p -r1.71 cp-lang.c *** cp-lang.c 23 Dec 2003 16:53:47 -0000 1.71 --- cp-lang.c 29 May 2004 00:02:52 -0000 *************** static void cxx_initialize_diagnostics ( *** 175,189 **** #undef LANG_HOOKS_TYPE_FOR_MODE #define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode #undef LANG_HOOKS_TYPE_FOR_SIZE #define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size #undef LANG_HOOKS_SIGNED_TYPE ! #define LANG_HOOKS_SIGNED_TYPE c_common_signed_type #undef LANG_HOOKS_UNSIGNED_TYPE ! #define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE ! #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type #undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR cxx_incomplete_type_error #undef LANG_HOOKS_TYPE_PROMOTES_TO #define LANG_HOOKS_TYPE_PROMOTES_TO cxx_type_promotes_to #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE --- 175,189 ---- #undef LANG_HOOKS_TYPE_FOR_MODE #define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode #undef LANG_HOOKS_TYPE_FOR_SIZE #define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size #undef LANG_HOOKS_SIGNED_TYPE ! #define LANG_HOOKS_SIGNED_TYPE cp_signed_type #undef LANG_HOOKS_UNSIGNED_TYPE ! #define LANG_HOOKS_UNSIGNED_TYPE cp_unsigned_type #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE ! #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE cp_signed_or_unsigned_type #undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR cxx_incomplete_type_error #undef LANG_HOOKS_TYPE_PROMOTES_TO #define LANG_HOOKS_TYPE_PROMOTES_TO cxx_type_promotes_to #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE Index: cp-tree.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v retrieving revision 1.946.4.12 diff -c -5 -p -r1.946.4.12 cp-tree.h *** cp-tree.h 28 May 2004 23:33:33 -0000 1.946.4.12 --- cp-tree.h 29 May 2004 00:02:53 -0000 *************** extern tree ovl_cons *** 4135,4144 **** --- 4135,4147 ---- extern tree build_overload (tree, tree); extern tree function_arg_chain (tree); extern int promotes_to_aggr_type (tree, enum tree_code); extern const char *cxx_printable_name (tree, int); extern tree build_exception_variant (tree, tree); + extern tree cp_signed_type (tree); + extern tree cp_unsigned_type (tree); + extern tree cp_signed_or_unsigned_type (int, tree); extern tree bind_template_template_parm (tree, tree); extern tree array_type_nelts_total (tree); extern tree array_type_nelts_top (tree); extern tree break_out_target_exprs (tree); extern tree get_type_decl (tree); Index: tree.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v retrieving revision 1.360.4.5 diff -c -5 -p -r1.360.4.5 tree.c *** tree.c 19 Mar 2004 07:13:37 -0000 1.360.4.5 --- tree.c 29 May 2004 00:02:53 -0000 *************** cp_build_type_attribute_variant (tree ty *** 1970,1979 **** --- 1970,2022 ---- new_type = build_exception_variant (new_type, TYPE_RAISES_EXCEPTIONS (type)); return new_type; } + static tree + build_enum_variant (tree type, bool unsigned_p) + { + tree v; + + /* See if we already have this variant. */ + for (v = TYPE_MAIN_VARIANT (type); v; v = TYPE_NEXT_VARIANT (v)) + { + tree t = TREE_CODE (v) == TYPE_DECL ? TREE_TYPE (v) : v; + if (TREE_UNSIGNED (t) == unsigned_p) + return t; + } + + v = build_type_copy (type); + TREE_UNSIGNED (v) = unsigned_p; + return v; + } + + tree + cp_signed_type (tree type) + { + if (TREE_CODE (type) == ENUMERAL_TYPE && TREE_UNSIGNED (type)) + return build_enum_variant (type, /*unsigned_p=*/false); + return c_common_signed_type (type); + } + + tree + cp_unsigned_type (tree type) + { + if (TREE_CODE (type) == ENUMERAL_TYPE && !TREE_UNSIGNED (type)) + return build_enum_variant (type, /*unsigned_p=*/true); + return c_common_unsigned_type (type); + } + + tree + cp_signed_or_unsigned_type (int unsigned_p, tree type) + { + if (TREE_CODE (type) == ENUMERAL_TYPE + && TREE_UNSIGNED (type) != unsigned_p) + return build_enum_variant (type, unsigned_p); + return c_common_signed_or_unsigned_type (unsigned_p, type); + } + /* Apply FUNC to all language-specific sub-trees of TP in a pre-order traversal. Called from walk_tree(). */ tree cp_walk_subtrees (tree* tp,