diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java index e99d06cbf2ad..f51ac1972979 100644 --- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java +++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java @@ -642,6 +642,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor { pushUnknown(); final ConditionalGotoInstruction branch = new ConditionalGotoInstruction(-1, false, null); addInstruction(branch); + addInstruction(new EmptyStackInstruction()); addInstruction(new GosubInstruction(cd.getJumpOffset())); addInstruction(new ReturnInstruction()); branch.setOffset(myCurrentFlow.getInstructionCount()); @@ -651,6 +652,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor { pushUnknown(); final ConditionalGotoInstruction branch = new ConditionalGotoInstruction(-1, false, null); addInstruction(branch); + addInstruction(new EmptyStackInstruction()); addInstruction(new PushInstruction(myFactory.getNotNullFactory().create(myRuntimeException), null)); addGotoCatch(cd); branch.setOffset(myCurrentFlow.getInstructionCount()); diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/TryCatchInForNotComplex.java b/java/java-tests/testData/inspection/dataFlow/fixture/TryCatchInForNotComplex.java new file mode 100644 index 000000000000..909749168391 --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/fixture/TryCatchInForNotComplex.java @@ -0,0 +1,12 @@ +public class Bar { + public static void main(String[] args) { + for (String s : args) { + try { + System.out.println(s); + } + catch (Exception e) { + System.out.println(e); + } + } + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java index 22407c7359ce..f01b63465068 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionFixtureTest.java @@ -54,4 +54,5 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas public void testBigMethodNotComplex() throws Throwable { doTest(); } public void testTernaryInWhileNotComplex() throws Throwable { doTest(); } + public void testTryCatchInForNotComplex() throws Throwable { doTest(); } }