[cfe-commits] r135565 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGenCXX/init-incomplete-type.cpp
Eli Friedman
eli.friedman at gmail.com
Tue Jul 19 21:58:40 PDT 2011
On Tue, Jul 19, 2011 at 9:31 PM, Chris Lattner <sabre at nondot.org> wrote:
> Author: lattner
> Date: Tue Jul 19 23:31:01 2011
> New Revision: 135565
>
> URL: http://llvm.org/viewvc/llvm-project?rev=135565&view=rev
> Log:
> 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*).
>
> Modified:
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/test/CodeGenCXX/init-incomplete-type.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=135565&r1=135564&r2=135565&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Jul 19 23:31:01 2011
> @@ -1075,7 +1075,10 @@
> 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();
ConvertTypeForMem is for types of values in memory, ConvertType is for
types of values in registers. In this case, you want the latter.
-Eli
More information about the cfe-commits
mailing list