Fix C-style code generation for intrinsic function data in CALL statements#797
Merged
yutaro-sakamoto merged 4 commits intoMar 5, 2026
Conversation
* Fix invalid C-style code generation for intrinsic function arguments in CALL statements
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Java/C-style code generation mismatch for intrinsic-function data when used in CALL ... USING ... so generated Java references the runtime module parameter storage instead of emitting C pointer syntax.
Changes:
- Update
cobj/codegen.cto emit Java access forCB_TAG_INTRINSICdata storage. - Add an integration test for
CALL ... USING FUNCTION UPPER-CASE(...). - Add (currently skipped) additional test cases for
CALL ... USING FUNCTION LENGTH(...)andMEAN(...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
cobj/codegen.c |
Switch intrinsic data emission from C-style parameter access to Java CobolModule.getCurrentModule().cob_procedure_parameters.get(i).getDataStorage() |
tests/run.src/functions.at |
Add CALL/USING intrinsic-function tests (1 enabled, 2 currently skipped) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
@tsh-hashimoto |
This was referenced Mar 5, 2026
Open
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#785 に関する修正
概要
joutput_data()のCB_TAG_INTRINSICケースで、C言語スタイルのコード生成(module.cob_procedure_parameters[%d]->data)を正しいJavaスタイル(CobolModule.getCurrentModule().cob_procedure_parameters.get(%d).getDataStorage())に変換joutput_call()の引数出力ループでfield_iterationが更新されていなかったバグを修正。複数のINTRINSIC引数を持つCALL文で誤ったインデックスが生成される問題を解消field_iterationがsetParametersループでのみ更新され、後続の引数出力ループでは更新されていなかったため、複数引数のCALL文で常に最後のインデックスが使われる問題があった。変更点
cobj/codegen.cjoutput_data()のCB_TAG_INTRINSICケースmodule.cob_procedure_parameters[%d]->dataをCobolModule.getCurrentModule().cob_procedure_parameters.get(%d).getDataStorage()に変換joutput_call()の引数出力ループfield_iteration = (int)n - 1;を追加。joutput_data()内のCB_TAG_INTRINSICケースが正しいインデックスを参照できるようにした。テスト
Warning
数値型INTRINSIC関数(FUNCTION LENGTH, FUNCTION MEANなど)の結果をCALL引数として渡す場合、INTRINSIC関数がCOB_TYPE_NUMERIC_BINARY 形式でデータを格納するのに対し、callee側がCOB_TYPE_NUMERIC_DISPLAY(ASCII数字)として解釈するため、正しく表示されない。これはopensource COBOLでも同様の動作であり、本PRのスコープ外とする。該当テストはスキップすることにした。