-
- Downloads
c++: Implement C++26 P2864R2 - Remove Deprecated Arithmetic Conversion on Enumerations From C++26
The following patch implements C++26 P2864R2 by emitting pedwarn enabled by the same options as the C++20 and later warnings (i.e. -Wenum-compare, -Wdeprecated-enum-enum-conversion and -Wdeprecated-enum-float-conversion which are all enabled by default). I think we still want to allow users some option workaround, so am not using directly error. Additionally, for cxx_dialect >= cxx26 && (complain & tf_warning_or_error) == 0 it causes for these newly ill-formed constructs error_mark_node to be silently returned. 2023-11-15 Jakub Jelinek <jakub@redhat.com> gcc/cp/ * typeck.cc: Implement C++26 P2864R2 - Remove Deprecated Arithmetic Conversion on Enumerations From C++26. (do_warn_enum_conversions): Return bool rather than void, add COMPLAIN argument. Use pedwarn rather than warning_at for C++26 and remove " is deprecated" part of the diagnostics in that case. For SFINAE in C++26 return true on newly erroneous cases. (cp_build_binary_op): For C++26 call do_warn_enum_conversions unconditionally, pass complain argument to it and if it returns true, return error_mark_node. * call.cc (build_conditional_expr): Use pedwarn rather than warning_at for C++26 and remove " is deprecated" part of the diagnostics in that case and check for complain & tf_warning_or_error. Use emit_diagnostic with cxx_dialect >= cxx26 ? DK_PEDWARN : DK_WARNING. For SFINAE in C++26 return error_mark_node on newly erroneous cases. (build_new_op): Use emit_diagnostic with cxx_dialect >= cxx26 ? DK_PEDWARN : DK_WARNING and complain & tf_warning_or_error check for C++26. For SFINAE in C++26 return error_mark_node on newly erroneous cases. gcc/testsuite/ * g++.dg/cpp26/enum-conv1.C: New test. * g++.dg/cpp2a/enum-conv1.C: Adjust expected diagnostics in C++26. * g++.dg/diagnostic/enum3.C: Likewise. * g++.dg/parse/attr3.C: Likewise. * g++.dg/cpp0x/linkage2.C: Likewise.
Showing
- gcc/cp/call.cc 36 additions, 12 deletionsgcc/cp/call.cc
- gcc/cp/typeck.cc 62 additions, 27 deletionsgcc/cp/typeck.cc
- gcc/testsuite/g++.dg/cpp0x/linkage2.C 2 additions, 1 deletiongcc/testsuite/g++.dg/cpp0x/linkage2.C
- gcc/testsuite/g++.dg/cpp26/enum-conv1.C 39 additions, 0 deletionsgcc/testsuite/g++.dg/cpp26/enum-conv1.C
- gcc/testsuite/g++.dg/cpp2a/enum-conv1.C 98 additions, 52 deletionsgcc/testsuite/g++.dg/cpp2a/enum-conv1.C
- gcc/testsuite/g++.dg/diagnostic/enum3.C 2 additions, 1 deletiongcc/testsuite/g++.dg/diagnostic/enum3.C
- gcc/testsuite/g++.dg/parse/attr3.C 2 additions, 1 deletiongcc/testsuite/g++.dg/parse/attr3.C
Loading
Please register or sign in to comment