diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-11-15 08:27:07 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-11-15 08:27:07 +0100 |
commit | 5f580e24088b85be95aeae0ceb2edff0cea861dd (patch) | |
tree | 4f79f88352efb01a9f67e0649f4bae325b5fd9bd /gcc/cp/tree.cc | |
parent | 081fddbbcf9790229f4fe885781548ba1f6a365a (diff) | |
download | gcc-5f580e24088b85be95aeae0ceb2edff0cea861dd.zip gcc-5f580e24088b85be95aeae0ceb2edff0cea861dd.tar.gz gcc-5f580e24088b85be95aeae0ceb2edff0cea861dd.tar.bz2 |
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.
Diffstat (limited to 'gcc/cp/tree.cc')
0 files changed, 0 insertions, 0 deletions