Fix crash due to trying to type convert ExprLists in DeclStmt.

(Regression from function pointer changes.)
This commit is contained in:
Matt Pharr
2011-11-05 09:35:43 -07:00
parent 5fc8df3e55
commit 51ccfffbd0

View File

@@ -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<ExprList *>(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)