summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmtAsm.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2014-09-18 18:17:18 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2014-09-18 18:17:18 +0000
commit974131ea8825041673a8c8dda7c42f9a9376eb17 (patch)
tree39e922e630d9141febda031d35e6786f196b4729 /clang/lib/Sema/SemaStmtAsm.cpp
parent3e6a0be4c4531d97134daea5bd32c5564e3d34f5 (diff)
downloadbcm5719-llvm-974131ea8825041673a8c8dda7c42f9a9376eb17.tar.gz
bcm5719-llvm-974131ea8825041673a8c8dda7c42f9a9376eb17.zip
[X86, inlineasm] Check that the output size is correct for the given constraint.
llvm-svn: 218064
Diffstat (limited to 'clang/lib/Sema/SemaStmtAsm.cpp')
-rw-r--r--clang/lib/Sema/SemaStmtAsm.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index 69cf6459d22..5aa1a2c86a9 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -121,6 +121,20 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
return StmtError();
OutputConstraintInfos.push_back(Info);
+
+ const Type *Ty = OutputExpr->getType().getTypePtr();
+
+ // If this is a dependent type, just continue. We don't know the size of a
+ // dependent type.
+ if (Ty->isDependentType())
+ continue;
+
+ unsigned Size = Context.getTypeSize(Ty);
+ if (!Context.getTargetInfo().validateOutputSize(Literal->getString(),
+ Size))
+ return StmtError(Diag(OutputExpr->getLocStart(),
+ diag::err_asm_invalid_output_size)
+ << Info.getConstraintStr());
}
SmallVector<TargetInfo::ConstraintInfo, 4> InputConstraintInfos;
OpenPOWER on IntegriCloud