Skip to content

Fix unused local scope codegen#212

Open
gshaowei6 wants to merge 1 commit into
Syncleus:masterfrom
gshaowei6:fix-unused-scope-codegen-96
Open

Fix unused local scope codegen#212
gshaowei6 wants to merge 1 commit into
Syncleus:masterfrom
gshaowei6:fix-unused-scope-codegen-96

Conversation

@gshaowei6
Copy link
Copy Markdown

Fixes #96.

BlockWriter previously threw CodeGenException: outOfScope... when javac emitted a store for an unused local at the end of a scope but omitted the corresponding LocalVariableTable entry. In that case the bytecode still contains the RHS expression, but there is no recoverable local name/type to declare in generated OpenCL.

This patch preserves the RHS expression for any potential side effects and suppresses the unrecoverable local assignment instead of throwing. It also enables the ignored ArbitraryScopeTest and updates NonNullCheckTest, which is the same unused-local-at-end-of-scope pattern.

Tests:

  • RED: after removing @Ignore from ArbitraryScopeTest, mvn "-Dtest=com.aparapi.codegen.test.ArbitraryScopeTest" test failed with CodeGenException: outOfScope193 = before the fix.
  • mvn "-Dtest=com.aparapi.codegen.test.ArbitraryScopeTest,com.aparapi.codegen.test.NonNullCheckTest,com.aparapi.codegen.test.NullCheckTest,com.aparapi.codegen.test.ArbitraryScopeSimpleTest,com.aparapi.codegen.test.ArbitraryScope2Test" test (10 tests, 0 failures)
  • mvn "-Dtest=com.aparapi.codegen.test.*Test" test completed; target/surefire-reports contains 434 tests, 0 failures, 0 errors, 2 skipped
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty $20] Unused variable at end of scope results in OutOfScope exceptions

1 participant