summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-11-12 06:42:51 +0000
committerBill Wendling <isanbard@gmail.com>2012-11-12 06:42:51 +0000
commit887b485dbe3dec6fb0387cf80c0e79f02bc7201d (patch)
tree22715c6291ab527da45b3e75c149743551bccf20 /clang/lib/Sema
parentb41000ed70a0699215399f8b17bf2d9526e74c56 (diff)
downloadbcm5719-llvm-887b485dbe3dec6fb0387cf80c0e79f02bc7201d.tar.gz
bcm5719-llvm-887b485dbe3dec6fb0387cf80c0e79f02bc7201d.zip
Check that the input size is correct for the given constraint.
The 'a', 'c', and 'd' constraints on i386 mean a 32-bit register. We cannot place a 64-bit value into the 32-bit register. Error out instead of causing the compiler to spew general badness. <rdar://problem/12415959> llvm-svn: 167717
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaStmtAsm.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index 7c2c766e461..e3b5dd851f0 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -179,6 +179,17 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
Exprs[i] = Result.take();
InputConstraintInfos.push_back(Info);
+
+ const Type *Ty = Exprs[i]->getType().getTypePtr();
+ if (Ty->isDependentType() || Ty->isIncompleteType())
+ continue;
+
+ unsigned Size = Context.getTypeSize(Ty);
+ if (!Context.getTargetInfo().validateInputSize(Literal->getString(),
+ Size))
+ return StmtError(Diag(InputExpr->getLocStart(),
+ diag::err_asm_invalid_input_size)
+ << Info.getConstraintStr());
}
// Check that the clobbers are valid.
OpenPOWER on IntegriCloud