[PATCH] D123649: Allow flexible array initialization in C++.
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 12 17:42:55 PDT 2022
efriedma created this revision.
efriedma added reviewers: aaron.ballman, rsmith, erichkeane.
Herald added a project: All.
efriedma requested review of this revision.
Herald added a project: clang.
Flexible array initialization is a C/C++ extension implemented in many compilers to allow initializing the flexible array tail of a struct type that contains a flexible array. In clang, this is currently restricted to C. But this construct is used in the Microsoft SDK headers, so I'd like to extend it to C++.
For now, this doesn't handle dynamic initialization; probably not hard to implement, but it's extra code, and I don't think it's necessary for the expected uses. And I'm not handling constant evaluation; it should fail gracefully.
I've added some additional code to assert that flexible array init works the way we expect it to in both C and C++.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123649
Files:
clang/include/clang/AST/Decl.h
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaInit.cpp
clang/test/CodeGenCXX/flexible-array-init.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123649.422371.patch
Type: text/x-patch
Size: 6439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220413/99ef031c/attachment.bin>
More information about the cfe-commits
mailing list