We didn't support the following syntax:
(std::initializer_list<int>){12}
which suddenly produces CompoundLiteralExpr that contains
CXXStdInitializerListExpr.
Lift the assertion and instead pass the value through CompoundLiteralExpr
transparently, as it doesn't add much.
Differential Revision: https://reviews.llvm.org/D39803
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319058
91177308-0d34-0410-b5e6-
96231b3b80d8
const Expr *Init = CL->getInitializer();
SVal V = State->getSVal(CL->getInitializer(), LCtx);
- if (isa<CXXConstructExpr>(Init)) {
+ if (isa<CXXConstructExpr>(Init) || isa<CXXStdInitializerListExpr>(Init)) {
// No work needed. Just pass the value up to this expression.
} else {
assert(isa<InitListExpr>(Init));
struct C {
C(std::initializer_list<int *> list);
};
-void foo() {
+void testPointerEscapeIntoLists() {
C empty{}; // no-crash
// Do not warn that 'x' leaks. It might have been deleted by
int *x = new int;
C c{x}; // no-warning
}
+
+void testPassListsWithExplicitConstructors() {
+ (void)(std::initializer_list<int>){12}; // no-crash
+}
}