From 74b777e5d18c4e568728c4aeb9966928bcb182bb Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 12 Jun 2014 20:47:21 +0000 Subject: Support -Wabi warning about backward compatibility. gcc/c-family/ * c.opt (Wabi=, fabi-compat-version): New. * c-opts.c (c_common_handle_option): Handle -Wabi=. (c_common_post_options): Handle flag_abi_compat_version default. Disallow -fabi-compat-version=1. * c-common.h (abi_version_crosses): New. gcc/cp/ * call.c (convert_arg_to_ellipsis): Use abi_version_crosses. * cvt.c (type_promotes_to): Likewise. * mangle.c (write_type, write_expression): Likewise. (write_name, write_template_arg): Likewise. (mangle_decl): Make alias based on flag_abi_compat_version. Emit -Wabi warning here. (finish_mangling_internal): Not here. Drop warn parm. (finish_mangling_get_identifier, finish_mangling): Adjust. (mangle_type_string, mangle_special_for_type): Adjust. (mangle_ctor_vtbl_for_type, mangle_thunk): Adjust. (mangle_guard_variable, mangle_tls_init_fn): Adjust. (mangle_tls_wrapper_fn, mangle_ref_init_variable): Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211594 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/cvt.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'gcc/cp/cvt.c') diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 2a827237f28..1dec9cc7f0e 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1701,13 +1701,9 @@ type_promotes_to (tree type) if (TREE_CODE (type) == BOOLEAN_TYPE) type = integer_type_node; - /* Scoped enums don't promote, but pretend they do for backward ABI bug - compatibility wrt varargs. */ - else if (SCOPED_ENUM_P (type) && abi_version_at_least (6)) - ; - /* Normally convert enums to int, but convert wide enums to something - wider. */ + wider. Scoped enums don't promote, but pretend they do for backward + ABI bug compatibility wrt varargs. */ else if (TREE_CODE (type) == ENUMERAL_TYPE || type == char16_type_node || type == char32_type_node @@ -1716,16 +1712,26 @@ type_promotes_to (tree type) int precision = MAX (TYPE_PRECISION (type), TYPE_PRECISION (integer_type_node)); tree totype = c_common_type_for_size (precision, 0); + tree prom = type; + if (TREE_CODE (prom) == ENUMERAL_TYPE) + prom = ENUM_UNDERLYING_TYPE (prom); + if (TYPE_UNSIGNED (prom) + && ! int_fits_type_p (TYPE_MAX_VALUE (prom), totype)) + prom = c_common_type_for_size (precision, 1); + else + prom = totype; if (SCOPED_ENUM_P (type)) - warning (OPT_Wabi, "scoped enum %qT will not promote to an integral " - "type in a future version of GCC", type); - if (TREE_CODE (type) == ENUMERAL_TYPE) - type = ENUM_UNDERLYING_TYPE (type); - if (TYPE_UNSIGNED (type) - && ! int_fits_type_p (TYPE_MAX_VALUE (type), totype)) - type = c_common_type_for_size (precision, 1); + { + if (abi_version_crosses (6) + && TYPE_MODE (prom) != TYPE_MODE (type)) + warning (OPT_Wabi, "scoped enum %qT passed through ... as " + "%qT before -fabi-version=6, %qT after", + type, prom, ENUM_UNDERLYING_TYPE (type)); + if (!abi_version_at_least (6)) + type = prom; + } else - type = totype; + type = prom; } else if (c_promoting_integer_type_p (type)) { -- cgit v1.2.1