From 66c203051f052cb2f9c550338fd966075a5bdcee Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 26 Aug 2011 18:41:18 +0000 Subject: [PATCH] In -Wno-error=non-pod-varargs, initialize a temporary with the crazy comma expression so that we get an r-value in the varargs position. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138638 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 19cd1184ff..e651f6dc2b 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -517,9 +517,18 @@ ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, ExprResult Comma = ActOnBinOp(TUScope, E->getLocStart(), tok::comma, Call.get(), E); if (Comma.isInvalid()) - return ExprError(); - + return ExprError(); E = Comma.get(); + + // Use that to initialize a temporary, or else we might get an + // l-value in a varargs position. + ExprResult Temp = PerformCopyInitialization( + InitializedEntity::InitializeTemporary(E->getType()), + E->getLocStart(), + Owned(E)); + if (Temp.isInvalid()) + return ExprError(); + E = Temp.get(); } } -- 2.50.1