[CodeGen] Fix the type of the constant that is used to zero-initialize a
authorAkira Hatanaka <ahatanaka@apple.com>
Tue, 23 May 2023 23:32:19 +0000 (16:32 -0700)
committerAkira Hatanaka <ahatanaka@apple.com>
Tue, 23 May 2023 23:32:27 +0000 (16:32 -0700)
commit6796053723a68b99149737439856e6da25953975
tree2b8b9a9efedf5ded8a7542e8ba32ac8d936d6d98
parent1f7c1741d6e294fcce754a22ad96a6352f3e1f21
[CodeGen] Fix the type of the constant that is used to zero-initialize a
flexible array member

A zero-element array type was incorrectly being used when an incomplete
array was being initialized with a non-empty initializer.

This fixes an assertion failure in AddInitializerToStaticVarDecl. See
the discussion here: https://reviews.llvm.org/D123649#4362210

Differential Revision: https://reviews.llvm.org/D151172
clang/lib/CodeGen/CGExprConstant.cpp
clang/test/CodeGenCXX/flexible-array-init.cpp