Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8672,6 +8672,8 @@ "invalid lvalue in asm input for constraint '%0'">; def err_asm_invalid_input_constraint : Error< "invalid input constraint '%0' in asm">; + def err_asm_immediate_expected : Error<"constraint '%0' expects " + "an integer constant expression">; def err_asm_tying_incompatible_types : Error< "unsupported inline asm: input with type " "%diff{$ matching output with type $|}0,1">; Index: clang/lib/Sema/SemaStmtAsm.cpp =================================================================== --- clang/lib/Sema/SemaStmtAsm.cpp +++ clang/lib/Sema/SemaStmtAsm.cpp @@ -394,6 +394,11 @@ << Info.getConstraintStr() << InputExpr->getSourceRange()); } else if (Info.requiresImmediateConstant() && !Info.allowsRegister()) { + if (InputExpr->getType()->isFunctionType()) { + return StmtError( + Diag(InputExpr->getBeginLoc(), diag::err_asm_immediate_expected) + << Info.getConstraintStr() << InputExpr->getSourceRange()); + } if (!InputExpr->isValueDependent()) { Expr::EvalResult EVResult; if (InputExpr->EvaluateAsRValue(EVResult, Context, true)) { @@ -410,7 +415,6 @@ << InputExpr->getSourceRange()); } } - } else { ExprResult Result = DefaultFunctionArrayLvalueConversion(Exprs[i]); if (Result.isInvalid()) Index: clang/test/Sema/inline-asm-validate-x86.c =================================================================== --- clang/test/Sema/inline-asm-validate-x86.c +++ clang/test/Sema/inline-asm-validate-x86.c @@ -130,3 +130,8 @@ __asm__ __volatile__("\n#define BEEF abcd%0\n" : : "n"((int*)0xdeadbeeeeeef)); #endif } + +void callee(void); +void caller(void) { + asm("call %0"::"n"(callee)); // expected-error{{constraint 'n' expects an integer constant expression}} +}