From 51ccfffbd09c0aa6b9bd79d1058d09e80f80448a Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Sat, 5 Nov 2011 09:35:43 -0700 Subject: [PATCH] Fix crash due to trying to type convert ExprLists in DeclStmt. (Regression from function pointer changes.) --- stmt.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stmt.cpp b/stmt.cpp index c75fd45d..978e40c8 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -318,11 +318,13 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const { // FIXME: we only need this for function pointers; it was // already done for atomic types and enums in // DeclStmt::TypeCheck()... - initExpr = TypeConvertExpr(initExpr, type, "initializer"); - // FIXME: and this is only needed to re-establish - // constant-ness so that GetConstant below works for - // constant artithmetic expressions... - initExpr = initExpr->Optimize(); + if (dynamic_cast(initExpr) == NULL) { + initExpr = TypeConvertExpr(initExpr, type, "initializer"); + // FIXME: and this is only needed to re-establish + // constant-ness so that GetConstant below works for + // constant artithmetic expressions... + initExpr = initExpr->Optimize(); + } cinit = initExpr->GetConstant(type); if (cinit == NULL)