[clang] Fix a crash when casting to an array type
authorAlan Zhao <ayzhao@google.com>
Mon, 17 Jul 2023 22:27:32 +0000 (15:27 -0700)
committerAlan Zhao <ayzhao@google.com>
Tue, 18 Jul 2023 16:48:17 +0000 (09:48 -0700)
commitfe0116aba833ee8597e2155d1e555c326acfaafc
treeec4997ab4a386c012af1bf50b043cb35376d5226
parentb0093e13fcfdd4eea5bbd7ae57d3d1b82f4135c3
[clang] Fix a crash when casting to an array type

In C++20, if Clang fails to perform constructor overload on a
RecordType, then Clang will try to perform parentesized aggregate
initialization. If that fails and the initialization was attempted as
part of a cast, then we should get the diagnostics from the failed
constructor overload attempt. However, we don't attempt constructor
overloading for arrays, so previously, if we try to diagnose an
overloaded cast for a parenthesized aggregate initialization of an
array, we crash. To fix this, we now exit tryDiagnoseOverloadedCast(...)
for failed parentesized list initialization if the destination type is
an array.

Fixes #63758

Reviewed By: aaron.ballman

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