summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-05-16 12:46:54 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-05-16 12:46:54 +0000
commite2cad6501576dbcdebb9e7c597c5fdcf620728d7 (patch)
tree87c9bdac9c4808abb754a7c6a33729647bfd3ec4 /clang/lib/Sema
parent54135838e20740c6115ed3085484e987cfceb53f (diff)
downloadbcm5719-llvm-e2cad6501576dbcdebb9e7c597c5fdcf620728d7.tar.gz
bcm5719-llvm-e2cad6501576dbcdebb9e7c597c5fdcf620728d7.zip
Add stricter checking for va_arg.
llvm-svn: 71942
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ea0d22ce253..4145be6ab76 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5208,15 +5208,21 @@ Sema::OwningExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
// Get the va_list type
QualType VaListType = Context.getBuiltinVaListType();
- // Deal with implicit array decay; for example, on x86-64,
- // va_list is an array, but it's supposed to decay to
- // a pointer for va_arg.
- if (VaListType->isArrayType())
+ if (VaListType->isArrayType()) {
+ // Deal with implicit array decay; for example, on x86-64,
+ // va_list is an array, but it's supposed to decay to
+ // a pointer for va_arg.
VaListType = Context.getArrayDecayedType(VaListType);
- // Make sure the input expression also decays appropriately.
- UsualUnaryConversions(E);
+ // Make sure the input expression also decays appropriately.
+ UsualUnaryConversions(E);
+ } else {
+ // Otherwise, the va_list argument must be an l-value because
+ // it is modified by va_arg.
+ if (CheckForModifiableLvalue(E, BuiltinLoc, *this))
+ return ExprError();
+ }
- if (CheckAssignmentConstraints(VaListType, E->getType()) != Compatible) {
+ if (!Context.hasSameType(VaListType, E->getType())) {
return ExprError(Diag(E->getLocStart(),
diag::err_first_argument_to_va_arg_not_of_type_va_list)
<< OrigExpr->getType() << E->getSourceRange());
OpenPOWER on IntegriCloud