c++: Reject float <=> enum.
authorMarek Polacek <polacek@redhat.com>
Wed, 28 Oct 2020 23:02:29 +0000 (19:02 -0400)
committerMarek Polacek <polacek@redhat.com>
Thu, 29 Oct 2020 18:06:13 +0000 (14:06 -0400)
commit79991e2348a864ace6ea2bf108a7502862f1129f
treea1208522e1a5783776514985cc2371947e4be5dc
parente1344fe7b6a96966281c78e46e777b456d5c2e19
c++: Reject float <=> enum.

As [depr.arith.conv.enum] says, these are ill-formed.

gcc/cp/ChangeLog:

* typeck.c (do_warn_enum_conversions): Don't warn for SPACESHIP_EXPR.
(cp_build_binary_op): Reject float <=> enum or enum <=> float.  Use
CP_INTEGRAL_TYPE_P instead of INTEGRAL_OR_ENUMERATION_TYPE_P.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/enum-conv1.C: Remove unused code.
* g++.dg/cpp2a/spaceship-err5.C: New test.
gcc/cp/typeck.c
gcc/testsuite/g++.dg/cpp2a/enum-conv1.C
gcc/testsuite/g++.dg/cpp2a/spaceship-err5.C [new file with mode: 0644]