This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix a crash with parenthesized aggregate initialization and base classes
ClosedPublic

Authored by ayzhao on Apr 26 2023, 3:10 PM.

Details

Summary

When calling InitializeBase(...), TryOrBuidlParenListInit(...) needs to
pass in the parent entity; otherwise, we erroneously try to cast
CurContext to a CXXConstructorDecl[0], which can't be done since we're
performing aggregate initialization, not constructor initialization.

Field initialization is not affected, but this patch still adds some
tests for it.

Fixes 62296

[0]: https://github.com/llvm/llvm-project/blob/33d6bd1c667456f7f4a9d338a7996a30a3af50a3/clang/lib/Sema/SemaAccess.cpp#L1696

Diff Detail

Event Timeline

ayzhao created this revision.Apr 26 2023, 3:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2023, 3:10 PM
ayzhao requested review of this revision.Apr 26 2023, 3:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2023, 3:10 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman accepted this revision.Apr 27 2023, 10:24 AM

LGTM, good catch! I think you should add a release note for this when landing, and this seems pretty reasonable to consider backporting to 16.x, WDYT?

This revision is now accepted and ready to land.Apr 27 2023, 10:24 AM
ayzhao updated this revision to Diff 517636.Apr 27 2023, 10:43 AM

add release note

I think you should add a release note for this when landing,

Done

and this seems pretty reasonable to consider backporting to 16.x, WDYT?

Agreed, given that this is a crash.

This revision was landed with ongoing or failed builds.Apr 27 2023, 10:43 AM
This revision was automatically updated to reflect the committed changes.