]> granicus.if.org Git - clang/commitdiff
PR5526: Make sure to set the right cast kinds for the inserted implicit casts.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 17 Nov 2009 01:22:05 +0000 (01:22 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 17 Nov 2009 01:22:05 +0000 (01:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89023 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CodeGen/conditional.c

index b089ffe92f35d21a78cd4dbce509315e5930c1ef..a74d50365e23f020ce49e1c65528cd86cc9c4829 100644 (file)
@@ -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;
     }
 
index 8a30463cb7e4b773065aee305f6e5a7c46d1887b..f55d59071a2fd9797bfa4c21e0496a0163147ec0 100644 (file)
@@ -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();
+}
+