diff options
Diffstat (limited to 'gcc/cp/call.cc')
-rw-r--r-- | gcc/cp/call.cc | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 86feff5..81b104f 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -6163,19 +6163,36 @@ build_conditional_expr (const op_location_t &loc, == DECL_CONTEXT (stripped_orig_arg3))) /* Two enumerators from the same enumeration can have different types when the enumeration is still being defined. */; - else if (complain & tf_warning) - warning_at (loc, OPT_Wenum_compare, "enumerated mismatch " - "in conditional expression: %qT vs %qT", - arg2_type, arg3_type); + else if (complain & (cxx_dialect >= cxx26 + ? tf_warning_or_error : tf_warning)) + emit_diagnostic (cxx_dialect >= cxx26 ? DK_PEDWARN : DK_WARNING, + loc, OPT_Wenum_compare, "enumerated mismatch " + "in conditional expression: %qT vs %qT", + arg2_type, arg3_type); + else if (cxx_dialect >= cxx26) + return error_mark_node; } - else if ((complain & tf_warning) - && warn_deprecated_enum_float_conv + else if ((((complain & (cxx_dialect >= cxx26 + ? tf_warning_or_error : tf_warning)) + && warn_deprecated_enum_float_conv) + || (cxx_dialect >= cxx26 + && (complain & tf_warning_or_error) == 0)) && ((TREE_CODE (arg2_type) == ENUMERAL_TYPE && SCALAR_FLOAT_TYPE_P (arg3_type)) || (SCALAR_FLOAT_TYPE_P (arg2_type) && TREE_CODE (arg3_type) == ENUMERAL_TYPE))) { - if (TREE_CODE (arg2_type) == ENUMERAL_TYPE) + if (cxx_dialect >= cxx26 && (complain & tf_warning_or_error) == 0) + return error_mark_node; + if (cxx_dialect >= cxx26 && TREE_CODE (arg2_type) == ENUMERAL_TYPE) + pedwarn (loc, OPT_Wdeprecated_enum_float_conversion, + "conditional expression between enumeration type " + "%qT and floating-point type %qT", arg2_type, arg3_type); + else if (cxx_dialect >= cxx26) + pedwarn (loc, OPT_Wdeprecated_enum_float_conversion, + "conditional expression between floating-point type " + "%qT and enumeration type %qT", arg2_type, arg3_type); + else if (TREE_CODE (arg2_type) == ENUMERAL_TYPE) warning_at (loc, OPT_Wdeprecated_enum_float_conversion, "conditional expression between enumeration type " "%qT and floating-point type %qT is deprecated", @@ -7258,11 +7275,18 @@ build_new_op (const op_location_t &loc, enum tree_code code, int flags, if (TREE_CODE (arg1_type) == ENUMERAL_TYPE && TREE_CODE (arg2_type) == ENUMERAL_TYPE && (TYPE_MAIN_VARIANT (arg1_type) - != TYPE_MAIN_VARIANT (arg2_type)) - && (complain & tf_warning)) - warning_at (loc, OPT_Wenum_compare, - "comparison between %q#T and %q#T", - arg1_type, arg2_type); + != TYPE_MAIN_VARIANT (arg2_type))) + { + if (cxx_dialect >= cxx26 + && (complain & tf_warning_or_error) == 0) + result = error_mark_node; + else if (cxx_dialect >= cxx26 || (complain & tf_warning)) + emit_diagnostic (cxx_dialect >= cxx26 + ? DK_PEDWARN : DK_WARNING, + loc, OPT_Wenum_compare, + "comparison between %q#T and %q#T", + arg1_type, arg2_type); + } break; default: break; |