When casting an enumerate with a fixed bool type the casting should use an IntegralToBoolean instead of an IntegralCast.
Fixes PR47055: Incorrect codegen for enum with bool underlying type
Paths
| Differential D85612
[Sema] Use proper integral cast for an enumerate with a fixed bool type ClosedPublic Authored by Mordante on Aug 9 2020, 9:19 AM.
Details Summary When casting an enumerate with a fixed bool type the casting should use an IntegralToBoolean instead of an IntegralCast. Fixes PR47055: Incorrect codegen for enum with bool underlying type
Diff Detail Event Timelinericcibruno added inline comments.
Mordante added inline comments.
Mordante added inline comments. This revision is now accepted and ready to land.Aug 15 2020, 7:03 AM Closed by commit rGfef260712407: [Sema] Use the proper cast for a fixed bool enum. (authored by Mordante). · Explain WhyAug 16 2020, 9:44 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 284478 clang/lib/Sema/SemaCast.cpp
clang/test/AST/ast-dump-enum-bool.cpp
clang/test/CodeGen/enum-bool.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp
|
I don't think we really need a dedicated AST test for this. Such tests create a maintenance burden, and they don't really capture what we care about here: that all non-zero values are correctly converted to the true value of the enumeration type.