summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index af69c231f1..4a3d26a5ab 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -191,12 +191,22 @@ static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) {
return false;
}
-/// Check the number of arguments, and set the result type to
+/// Check the number of arguments and arg type, and set the result type to
/// the argument type.
static bool SemaBuiltinPreserveAI(Sema &S, CallExpr *TheCall) {
if (checkArgCount(S, TheCall, 1))
return true;
+ // The argument type must be a pointer
+ ExprResult Arg = TheCall->getArg(0);
+ QualType Ty = Arg.get()->getType();
+ if (!Ty->isPointerType()) {
+ S.Diag(Arg.get()->getBeginLoc(),
+ diag::err_builtin_preserve_access_index_invalid_arg)
+ << Ty << Arg.get()->getSourceRange();
+ return true;
+ }
+
TheCall->setType(TheCall->getArg(0)->getType());
return false;
}