Fix pruning empty declarations from loop headers
Empty declarations are possible in loop init expressions. Make
PruneEmptyDeclarations take this into account.
BUG=angleproject:1550
TEST=angle_unittests
Change-Id: If407babf9b6f7a26dfcf73ff345493d3e2af3f9a
Reviewed-on: https://chromium-review.googlesource.com/401147
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/src/compiler/translator/PruneEmptyDeclarations.cpp b/src/compiler/translator/PruneEmptyDeclarations.cpp
index 695aa58..4763dd6 100644
--- a/src/compiler/translator/PruneEmptyDeclarations.cpp
+++ b/src/compiler/translator/PruneEmptyDeclarations.cpp
@@ -63,9 +63,17 @@
// float;
TIntermSequence emptyReplacement;
TIntermBlock *parentAsBlock = getParentNode()->getAsBlock();
- ASSERT(parentAsBlock != nullptr);
- mMultiReplacements.push_back(
- NodeReplaceWithMultipleEntry(parentAsBlock, node, emptyReplacement));
+ // The declaration may be inside a block or in a loop init expression.
+ ASSERT(parentAsBlock != nullptr || getParentNode()->getAsLoopNode() != nullptr);
+ if (parentAsBlock)
+ {
+ mMultiReplacements.push_back(
+ NodeReplaceWithMultipleEntry(parentAsBlock, node, emptyReplacement));
+ }
+ else
+ {
+ queueReplacement(node, nullptr, OriginalNode::IS_DROPPED);
+ }
}
else if (sym->getType().getQualifier() != EvqGlobal &&
sym->getType().getQualifier() != EvqTemporary)