diff options
| author | Chris Lattner <sabre@nondot.org> | 2011-07-20 04:31:01 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2011-07-20 04:31:01 +0000 |
| commit | 71bd0c32630971b125556cbdce2404f924133449 (patch) | |
| tree | d1aa6d26dba6c5636d35aeac1bb158eaad4820da /clang | |
| parent | b66d2555954f2c734be6745d305f7f1cfce638f0 (diff) | |
| download | bcm5719-llvm-71bd0c32630971b125556cbdce2404f924133449.tar.gz bcm5719-llvm-71bd0c32630971b125556cbdce2404f924133449.zip | |
fix PR10395 - array decay can produce an interesting type when
decaying an array of incomplete type (which has type [0 x i8]*) to a
normal pointer (which has incompletetype*).
llvm-svn: 135565
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 5 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/init-incomplete-type.cpp | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 37d424a2b35..f64e98ef684 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1075,7 +1075,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { V = Builder.CreateStructGEP(V, 0, "arraydecay"); } - return V; + // Make sure the array decay ends up being the right type. This matters if + // the array type was of an incomplete type. + return CGF.Builder.CreateBitCast(V, + CGF.getTypes().ConvertTypeForMem(CE->getType())); } case CK_FunctionToPointerDecay: return EmitLValue(E).getAddress(); diff --git a/clang/test/CodeGenCXX/init-incomplete-type.cpp b/clang/test/CodeGenCXX/init-incomplete-type.cpp index 1755dfb7beb..4f37eeb9754 100644 --- a/clang/test/CodeGenCXX/init-incomplete-type.cpp +++ b/clang/test/CodeGenCXX/init-incomplete-type.cpp @@ -28,4 +28,10 @@ namespace incomplete_type_refs { return &g[1]; } -}
\ No newline at end of file +} + +namespace PR10395 { + struct T; + extern T x[]; + T* f() { return x; } +} |

