diff options
author | Anders Carlsson <andersca@mac.com> | 2009-01-20 20:49:22 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-01-20 20:49:22 +0000 |
commit | d9fca6e3950346ea503f92f27ed0f9d8edde9feb (patch) | |
tree | 55d78b759ae40751a9a744ab946cda622a56b23c /lib/Sema/SemaStmt.cpp | |
parent | 83bccb85ff4b9981c4250c45494b439df8cbf983 (diff) |
Improvements to Sema of asm statements. Fixes <rdar://problem/6156893>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62609 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 9e15c21f5a..4b89acb690 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -896,18 +896,27 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, diag::err_asm_invalid_input_constraint) << InputConstraint); } - // Check that the input exprs aren't of type void. ParenExpr *InputExpr = cast<ParenExpr>(Exprs[i]); - if (InputExpr->getType()->isVoidType()) { - return StmtError(Diag(InputExpr->getSubExpr()->getLocStart(), - diag::err_asm_invalid_type_in_input) - << InputExpr->getType() << InputConstraint - << InputExpr->getSubExpr()->getSourceRange()); + // Only allow void types for memory constraints. + if (info & TargetInfo::CI_AllowsMemory) { + + if (InputExpr->isLvalue(Context) != Expr::LV_Valid) + return StmtError(Diag(InputExpr->getSubExpr()->getLocStart(), + diag::err_asm_invalid_lvalue_in_input) + << InputConstraint << InputExpr->getSubExpr()->getSourceRange()); } - if (info & TargetInfo::CI_AllowsRegister) + if (info & TargetInfo::CI_AllowsRegister) { + if (InputExpr->getType()->isVoidType()) { + return StmtError(Diag(InputExpr->getSubExpr()->getLocStart(), + diag::err_asm_invalid_type_in_input) + << InputExpr->getType() << InputConstraint + << InputExpr->getSubExpr()->getSourceRange()); + } + DefaultFunctionArrayConversion(Exprs[i]); + } } // Check that the clobbers are valid. |