aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-11-17 01:22:05 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-11-17 01:22:05 +0000
commit16fea9b2e5888443a6e2f96b397c92d3f6710ee8 (patch)
treed01a59320152535c1fd9d936bc7eea239b8cb7d9
parentfa1a06e80706846fa15e0bd44671bdc3dfc53d84 (diff)
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
-rw-r--r--lib/Sema/SemaExpr.cpp4
-rw-r--r--test/CodeGen/conditional.c8
2 files changed, 10 insertions, 2 deletions
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();
+}
+