This is an archive of the discontinued LLVM Phabricator instance.

[SemaCXX] Set promotion type for enum if its type is promotable to integer type even if it has no definition.
ClosedPublic

Authored by zequanwu on Jul 20 2022, 4:11 PM.

Details

Summary

EnumDecl's promotion type is set either to the parsed type or calculated type
after completing its definition. When it's bool type and has no definition,
its promotion type is bool which is not allowed by clang.

This fixes https://github.com/llvm/llvm-project/issues/56560.

Diff Detail

Event Timeline

zequanwu created this revision.Jul 20 2022, 4:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 4:11 PM
zequanwu requested review of this revision.Jul 20 2022, 4:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 4:11 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
shafik added a comment.EditedJul 20 2022, 10:52 PM

Thank you for working on this.

We seem to have a few tests with enums that bool as a specified type. Maybe this belongs better in one of those under the namespace GH56560

I am curious that this does not change the test results of clang/test/CXX/conv/conv.prom/p4.cpp

aaron.ballman added inline comments.Jul 21 2022, 5:51 AM
clang/lib/Sema/SemaDecl.cpp
16198–16201
16824–16828

Same here as above

zequanwu updated this revision to Diff 446551.Jul 21 2022, 10:10 AM
zequanwu marked 2 inline comments as done.
  • Address comment.
  • Move test to clang/test/CXX/conv/conv.prom/p4.cpp.

I am curious that this does not change the test results of clang/test/CXX/conv/conv.prom/p4.cpp

The crash only happens when the enum is bool and has no definition.

zequanwu retitled this revision from [SemaCXX] Set promotion type for enum bool to integer type. to [SemaCXX] Set promotion type for enum if its type is promotable to integer type even if it has no definition..Jul 21 2022, 10:40 AM
aaron.ballman accepted this revision.Jul 21 2022, 11:03 AM

LGTM, though you should add a release note to clang/docs/ReleaseNotes.rst for the bug fix. Thank you!

This revision is now accepted and ready to land.Jul 21 2022, 11:03 AM
This revision was landed with ongoing or failed builds.Jul 21 2022, 11:23 AM
This revision was automatically updated to reflect the committed changes.

LGTM, though you should add a release note to clang/docs/ReleaseNotes.rst for the bug fix. Thank you!

Added a release note.