From 03f3db1e8971f415959fccf098cfa9452364a652 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 8 Dec 2011 14:58:52 -0800 Subject: [PATCH] Fix bugs in ForeachStmt::TypeCheck() and Optimize() methods. Specifically, we weren't storing the results passed back from when we called those methods of the start and end exprs. This manifested itself as overloaded functions there not resolving properly. --- stmt.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/stmt.cpp b/stmt.cpp index a53236aa..e10616b5 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -1945,12 +1945,12 @@ ForeachStmt::Optimize() { bool anyErrors = false; for (unsigned int i = 0; i < startExprs.size(); ++i) { if (startExprs[i] != NULL) - startExprs[i]->Optimize(); + startExprs[i] = startExprs[i]->Optimize(); anyErrors |= (startExprs[i] == NULL); } for (unsigned int i = 0; i < endExprs.size(); ++i) { if (endExprs[i] != NULL) - endExprs[i]->Optimize(); + endExprs[i] = endExprs[i]->Optimize(); anyErrors |= (endExprs[i] == NULL); } @@ -1966,20 +1966,21 @@ Stmt * ForeachStmt::TypeCheck() { bool anyErrors = false; for (unsigned int i = 0; i < startExprs.size(); ++i) { + // Typecheck first, to resolve function overloads + if (startExprs[i] != NULL) + startExprs[i] = startExprs[i]->TypeCheck(); if (startExprs[i] != NULL) startExprs[i] = TypeConvertExpr(startExprs[i], AtomicType::UniformInt32, "foreach starting value"); - if (startExprs[i] != NULL) - startExprs[i]->TypeCheck(); anyErrors |= (startExprs[i] == NULL); } for (unsigned int i = 0; i < endExprs.size(); ++i) { + if (endExprs[i] != NULL) + endExprs[i] = endExprs[i]->TypeCheck(); if (endExprs[i] != NULL) endExprs[i] = TypeConvertExpr(endExprs[i], AtomicType::UniformInt32, "foreach ending value"); - if (endExprs[i] != NULL) - endExprs[i]->TypeCheck(); anyErrors |= (endExprs[i] == NULL); }