From 974131ea8825041673a8c8dda7c42f9a9376eb17 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Thu, 18 Sep 2014 18:17:18 +0000 Subject: [X86, inlineasm] Check that the output size is correct for the given constraint. llvm-svn: 218064 --- clang/lib/Sema/SemaStmtAsm.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'clang/lib/Sema') 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 InputConstraintInfos; -- cgit v1.2.3