GCC compatibility: gcc allows applying va_args to const

va_lists for some reason.  This fixes rdar://6726818

llvm-svn: 68434
This commit is contained in:
Chris Lattner 2009-04-05 00:52:59 +00:00
parent b4d7102417
commit 9e658eccab
2 changed files with 11 additions and 1 deletions

View 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());

View 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);
}