]> granicus.if.org Git - clang/commitdiff
In -Wno-error=non-pod-varargs, initialize a temporary with
authorJohn McCall <rjmccall@apple.com>
Fri, 26 Aug 2011 18:41:18 +0000 (18:41 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 26 Aug 2011 18:41:18 +0000 (18:41 +0000)
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

index 19cd1184ffdb7a12cdd1e05594886357fcf0589a..e651f6dc2b74858898d4ab31e15407b5ecde329c 100644 (file)
@@ -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();
     }
   }