]> granicus.if.org Git - clang/commitdiff
GCC compatibility: gcc allows applying va_args to const
authorChris Lattner <sabre@nondot.org>
Sun, 5 Apr 2009 00:52:59 +0000 (00:52 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 5 Apr 2009 00:52:59 +0000 (00:52 +0000)
va_lists for some reason.  This fixes rdar://6726818

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

lib/Sema/SemaExpr.cpp
test/Sema/varargs.c

index 55eaaa4bc868fd987810549712d38b01e9604aa1..a43c2c370e3cc8683a062c16b161acac53ea461f 100644 (file)
@@ -4724,7 +4724,10 @@ Sema::OwningExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
   Expr *E = static_cast<Expr*>(expr.get());
   UsualUnaryConversions(E);
 
-  if (CheckAssignmentConstraints(VaListType, E->getType()) != Compatible)
+  AssignConvertType ConvResult = 
+    CheckAssignmentConstraints(VaListType, E->getType());
+  if (ConvResult != Compatible &&
+      ConvResult != CompatiblePointerDiscardsQualifiers)
     return ExprError(Diag(E->getLocStart(),
                          diag::err_first_argument_to_va_arg_not_of_type_va_list)
       << E->getType() << E->getSourceRange());
index 434e4ce291d27e1d273d41a74a2c59f62a851f1a..7255f9fc061512940c23bd5cf11d5cb8cdfb4656 100644 (file)
@@ -60,3 +60,10 @@ void f7(int a, ...) {
   int *x = &__builtin_va_arg(ap, int); // expected-error {{address expression must be an lvalue or a function designator}}
   __builtin_va_end(ap);
 }
+
+// rdar://6726818
+void f8() {
+  const __builtin_va_list args2;
+  (void)__builtin_va_arg(args2, int);
+}
+