aparapi icon indicating copy to clipboard operation
aparapi copied to clipboard

Fix inline local declarations in assignment expressions

Open OnlyYu1996 opened this issue 6 months ago • 0 comments

Fixes #97. Fixes #99.

This teaches the OpenCL writer to hoist local declarations that appear inside inline assignment expressions to the start of the current block. The original inline assignment expression is then emitted as a normal assignment, avoiding invalid OpenCL such as result = int assignMe = value and avoiding the previous CodeGenException for declarations in argument expressions.

The scan deliberately skips for-header and arbitrary-scope composites so existing scoped declarations keep their current output shape.

Validation:

  • mvn -q -Dstyle.color=never -Dtest=AssignAndPassAsParameterSimpleTest,FirstAssignInExpression2Test,AssignAndPassAsParameterTest,FirstAssignInExpressionTest test
  • mvn -q -Dstyle.color=never -Dtest=com.aparapi.codegen.test.*Test test
  • mvn -q -Dstyle.color=never -DskipTests test-compile
  • git diff --check

OnlyYu1996 avatar May 16 '26 20:05 OnlyYu1996