diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2009-11-17 01:22:05 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2009-11-17 01:22:05 +0000 |
| commit | b0bc559b1963e9dc95091baa53ccedbddb02368c (patch) | |
| tree | 810472ef01bce3d95ad6118530a865865e5917c9 | |
| parent | af1ad30a236929de5c300343e0858401619c4bdd (diff) | |
| download | bcm5719-llvm-b0bc559b1963e9dc95091baa53ccedbddb02368c.tar.gz bcm5719-llvm-b0bc559b1963e9dc95091baa53ccedbddb02368c.zip | |
PR5526: Make sure to set the right cast kinds for the inserted implicit casts.
llvm-svn: 89023
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 4 | ||||
| -rw-r--r-- | clang/test/CodeGen/conditional.c | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index b089ffe92f3..a74d50365e2 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/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/clang/test/CodeGen/conditional.c b/clang/test/CodeGen/conditional.c index 8a30463cb7e..f55d59071a2 100644 --- a/clang/test/CodeGen/conditional.c +++ b/clang/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(); +} + |

