Fixed bug 878608: Error in reporting UnusedLocalVariable for multi-dimensional array index.

This commit is contained in:
Rick Giles 2004-01-17 15:28:18 +00:00
parent 2dda964c91
commit ddff555c2d
3 changed files with 22 additions and 0 deletions

View File

@ -130,6 +130,10 @@
<li class="body">JDK 1.4 classes used by usage checks.
(bug 876570)</li>
<li class="body">Error in reporting UnusedLocalVariable for
multi-dimensional array index.
(bug 878608)</li>
</ul>
<p class="body">

View File

@ -928,11 +928,19 @@ public class Resolver extends DefinitionTraverser {
SymTabAST arrayNode = (SymTabAST) (node.getFirstChild());
SymTabAST exprNode = (SymTabAST) (arrayNode.getNextSibling());
//resolve index expressions
while (arrayNode.getType() == TokenTypes.INDEX_OP) {
resolveExpression(exprNode, location, context, referencePhase);
arrayNode = (SymTabAST) (arrayNode.getFirstChild());
exprNode = (SymTabAST) (arrayNode.getNextSibling());
}
ArrayDef array =
(ArrayDef) resolveExpression(arrayNode,
location,
context,
referencePhase);
resolveExpression(exprNode, location, context, referencePhase);
return array.getType();

View File

@ -47,4 +47,14 @@ public class InputUnusedLocal
if (file != null) {
}
}
/** tests array index references */
public void testArrayIndex()
{
int [][][] a = new int[1][1][1];
int i = 0;
int j = 0;
int k = 0;
a[i][j][k]++;
}
}