]> granicus.if.org Git - clang/commitdiff
Fix va_arg bug noticed by Eli, __builtin_va_arg is not an l-value
authorDaniel Dunbar <daniel@zuster.org>
Thu, 12 Feb 2009 09:21:08 +0000 (09:21 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 12 Feb 2009 09:21:08 +0000 (09:21 +0000)
designating an object.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64371 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
test/Sema/varargs.c

index 95a6a349f31d333aa00edd8673900ff53f89c7ed..7b06a3c1ce693ee4fd36e91b4a11cf66a7ce0793 100644 (file)
@@ -565,7 +565,7 @@ Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const {
   case PredefinedExprClass:
     return LV_Valid;
   case VAArgExprClass:
-    return LV_Valid;
+    return LV_NotObjectType;
   case CXXDefaultArgExprClass:
     return cast<CXXDefaultArgExpr>(this)->getExpr()->isLvalue(Ctx);
   case CXXConditionDeclExprClass:
index ae21c208eb8ada9088f1c7a4ea15a6fce13df127..b340177f9c5ee03dc10b791a14467b9dc9f702a1 100644 (file)
@@ -52,3 +52,11 @@ foo(__builtin_va_list authors, ...) {
   __builtin_va_end (authors);
 }
 
+void f7(int a, ...) {
+  __builtin_va_list ap;
+  __builtin_va_start(ap, a);
+  // FIXME: This error message is sub-par.
+  __builtin_va_arg(ap, int) = 1; // expected-error {{non-object type 'int' is not assignable}}
+  int *x = &__builtin_va_arg(ap, int); // expected-error {{address expression must be an lvalue or a function designator}}
+  __builtin_va_end(ap);
+}