From 4da89c87b2b6ca31f1015ec19aae65a02971ea9a Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 10 May 2011 23:39:47 +0000 Subject: [PATCH] Use a heralded conversion to bool in inline-asm constraints. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131170 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaStmt.cpp | 4 +++- test/Sema/asm.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index a60fcb7097..60fcb10d53 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -2016,7 +2016,9 @@ StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, bool IsSimple, if (InputDomain == AD_Int && OutputDomain == AD_Int && !isOperandMentioned(InputOpNo, Pieces) && InputExpr->isEvaluatable(Context)) { - InputExpr = ImpCastExprToType(InputExpr, OutTy, CK_IntegralCast).take(); + CastKind castKind = + (OutTy->isBooleanType() ? CK_IntegralToBoolean : CK_IntegralCast); + InputExpr = ImpCastExprToType(InputExpr, OutTy, castKind).take(); Exprs[InputOpNo] = InputExpr; NS->setInputExpr(i, InputExpr); continue; diff --git a/test/Sema/asm.c b/test/Sema/asm.c index 7f0f396b9d..d8161c819b 100644 --- a/test/Sema/asm.c +++ b/test/Sema/asm.c @@ -105,3 +105,11 @@ void test10(void){ register int r asm ("cx"); register int rr asm ("rr_asm"); // expected-error{{unknown register name 'rr_asm' in asm}} } + +// This is just an assert because of the boolean conversion. +// Feel free to change the assembly to something sensible if it causes a problem. +// rdar://problem/9414925 +void test11(void) { + _Bool b; + asm volatile ("movb %%gs:%P2,%b0" : "=q"(b) : "0"(0), "i"(5L)); +} -- 2.40.0