aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp23
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.