From 2f8df98c92e1b98aeb0b3a76a13f60ce8c438f0d Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 3 Sep 2010 02:07:00 +0000 Subject: [PATCH] IRgen: Fix silly thinko in r112021, which was generating code for the same expr twice. This showed up as an assert on the odd test case because we generated the decl map entry twice. llvm-svn: 112943 --- clang/lib/CodeGen/CGExprScalar.cpp | 2 +- clang/test/CodeGen/_Bool-conversion.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index fd77a67606b3..4e16f66ba422 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1033,7 +1033,7 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { // Handle conversion to bool correctly. if (DestTy->isBooleanType()) - return EmitScalarConversion(Visit(E), E->getType(), DestTy); + return EmitScalarConversion(Src, E->getType(), DestTy); return Builder.CreatePtrToInt(Src, ConvertType(DestTy)); } diff --git a/clang/test/CodeGen/_Bool-conversion.c b/clang/test/CodeGen/_Bool-conversion.c index fce7ada30a5f..9e5e89450314 100644 --- a/clang/test/CodeGen/_Bool-conversion.c +++ b/clang/test/CodeGen/_Bool-conversion.c @@ -6,3 +6,7 @@ static _Bool f0_0(void *a0) { return (_Bool) a0; } int f0() { return f0_0((void*) 0x2); } + +_Bool f1(void) { + return (_Bool) ({ void (*x)(); x = 0; }); +}