Index: lib/CodeGen/CGStmt.cpp =================================================================== --- lib/CodeGen/CGStmt.cpp +++ lib/CodeGen/CGStmt.cpp @@ -1837,7 +1837,8 @@ // If this can't be a register or memory, i.e., has to be a constant // (immediate or symbolic), try to emit it as such. if (!Info.allowsRegister() && !Info.allowsMemory()) { - if (Info.requiresImmediateConstant()) { + // We can delay diagnosing the "n" constraint until after inlining. + if (Info.requiresImmediateConstant() && ConstraintStr != "n") { Expr::EvalResult EVResult; InputExpr->EvaluateAsRValue(EVResult, getContext(), true); Index: lib/Sema/SemaStmtAsm.cpp =================================================================== --- lib/Sema/SemaStmtAsm.cpp +++ lib/Sema/SemaStmtAsm.cpp @@ -381,7 +381,8 @@ } else if (Info.requiresImmediateConstant() && !Info.allowsRegister()) { if (!InputExpr->isValueDependent()) { Expr::EvalResult EVResult; - if (!InputExpr->EvaluateAsRValue(EVResult, Context, true)) + if (!InputExpr->EvaluateAsRValue(EVResult, Context, true) && + Literal->getString() != "n") return StmtError( Diag(InputExpr->getBeginLoc(), diag::err_asm_immediate_expected) << Info.getConstraintStr() << InputExpr->getSourceRange()); @@ -395,7 +396,7 @@ Diag(InputExpr->getBeginLoc(), diag::err_asm_immediate_expected) << Info.getConstraintStr() << InputExpr->getSourceRange()); - if (!Info.isValidAsmImmediate(IntResult)) + if (!Info.isValidAsmImmediate(IntResult) && Literal->getString() != "n") return StmtError(Diag(InputExpr->getBeginLoc(), diag::err_invalid_asm_value_for_constraint) << IntResult.toString(10) << Info.getConstraintStr()