From: Eli Friedman Date: Tue, 17 Nov 2009 01:22:05 +0000 (+0000) Subject: PR5526: Make sure to set the right cast kinds for the inserted implicit casts. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16fea9b2e5888443a6e2f96b397c92d3f6710ee8;p=clang PR5526: Make sure to set the right cast kinds for the inserted implicit casts. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89023 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index b089ffe92f..a74d50365e 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -3584,9 +3584,9 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, = Context.getQualifiedType(rhptee, lhptee.getQualifiers()); QualType destType = Context.getPointerType(destPointee); // Add qualifiers if necessary. - ImpCastExprToType(LHS, destType, CastExpr::CK_NoOp); + ImpCastExprToType(RHS, destType, CastExpr::CK_NoOp); // Promote to void*. - ImpCastExprToType(RHS, destType, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, destType, CastExpr::CK_BitCast); return destType; } diff --git a/test/CodeGen/conditional.c b/test/CodeGen/conditional.c index 8a30463cb7..f55d59071a 100644 --- a/test/CodeGen/conditional.c +++ b/test/CodeGen/conditional.c @@ -39,3 +39,11 @@ void _php_stream_free3() { void _php_stream_free4() { 1 ? _efree(0) : free(0); } + +// PR5526 +struct test9 { int a; }; +void* test9spare(); +void test9(struct test9 *p) { + p ? p : test9spare(); +} +