aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-08-26 18:41:18 +0000
committerJohn McCall <rjmccall@apple.com>2011-08-26 18:41:18 +0000
commit66c203051f052cb2f9c550338fd966075a5bdcee (patch)
tree1e45f0cf2959b6eb229742c5ee9d23ec3aa38499 /lib/Sema/SemaExpr.cpp
parent807179763b87a24de26b3c89e7ae9e898bab420c (diff)
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
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp13
1 files 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();
}
}