[clang] Fix a crash with parenthesized aggregate initialization and base classes
authorAlan Zhao <ayzhao@google.com>
Wed, 26 Apr 2023 21:50:01 +0000 (14:50 -0700)
committerAlan Zhao <ayzhao@google.com>
Thu, 27 Apr 2023 17:43:16 +0000 (10:43 -0700)
commit7417e9d75c9af7dd0d3dad12eebdee84b10b56d7
tree8d8b6be555fd629430fcf27470e6896a0708aaa2
parent48ed7c43892bdb43e52222add97660031da4d410
[clang] Fix a crash with parenthesized aggregate initialization and base classes

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

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D149301
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaInit.cpp
clang/test/SemaCXX/paren-list-agg-init.cpp