Skip to content

Commit caf9f31

Browse files
committed
Fix check in cb_check_conformance
1 parent 35e8c3b commit caf9f31

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

cobc/ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
2024-08-14 Nicolas Berthier <[email protected]>
33

44
* cobc.c (cobc_print_info): added note for Java interoperability
5+
* typeck.c, tree.h (cb_check_conformance): pass call convention to deal
6+
with calls of Java methods
57

68
2024-08-04 David Declerck <[email protected]>
79

cobc/parser.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12257,13 +12257,13 @@ call_body:
1225712257
if (strncasecmp("Java.", (char *)CB_LITERAL ($3)->data, 5) == 0) {
1225812258
call_conv = CB_CONV_JAVA;
1225912259
}
12260-
cb_check_conformance ($3, $7, $8);
12260+
cb_check_conformance ($3, $7, $8, call_conv);
1226112261
} else if (CB_REFERENCE_P ($3)) {
1226212262
cb_tree ref = cb_ref ($3);
1226312263
if ((CB_FIELD_P (ref) && CB_FIELD (ref)->flag_item_78)
1226412264
|| CB_PROGRAM_P (ref)
1226512265
|| CB_PROTOTYPE_P (ref)) {
12266-
cb_check_conformance ($3, $7, $8);
12266+
cb_check_conformance ($3, $7, $8, call_conv);
1226712267
}
1226812268
}
1226912269

cobc/tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2592,7 +2592,7 @@ extern cb_tree cb_build_write_advancing_lines (cb_tree, cb_tree);
25922592
extern cb_tree cb_build_write_advancing_mnemonic (cb_tree, cb_tree);
25932593
extern cb_tree cb_build_write_advancing_page (cb_tree);
25942594
extern cb_tree cb_check_sum_field (cb_tree x);
2595-
extern void cb_check_conformance (cb_tree, cb_tree, cb_tree);
2595+
extern void cb_check_conformance (cb_tree, cb_tree, cb_tree, int);
25962596
extern void cb_emit_initiate (cb_tree rep);
25972597
extern void cb_emit_terminate (cb_tree rep);
25982598
extern void cb_emit_generate (cb_tree rep);

cobc/typeck.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3921,7 +3921,7 @@ check_argument_conformance (struct cb_program *program, cb_tree argument_tripple
39213921

39223922
void
39233923
cb_check_conformance (cb_tree prog_ref, cb_tree using_list,
3924-
cb_tree returning)
3924+
cb_tree returning, int call_conv)
39253925
{
39263926
struct cb_program *program = NULL;
39273927
cb_tree l;
@@ -3932,6 +3932,24 @@ cb_check_conformance (cb_tree prog_ref, cb_tree using_list,
39323932
const struct cb_field *prog_returning_field;
39333933
const struct cb_field *call_returning_field;
39343934

3935+
if (call_conv == CB_CONV_JAVA && CB_LITERAL_P (prog_ref)) {
3936+
char *full_name, *class_and_method_name, *dot;
3937+
full_name = (char *)CB_LITERAL(prog_ref)->data;
3938+
class_and_method_name = full_name + 5;
3939+
dot = strchr (class_and_method_name, '.');
3940+
if (dot == NULL) {
3941+
cb_error_x (prog_ref, _("malformed Java method name '%s', "
3942+
"expected format 'Java.ClassName.methodName'"),
3943+
full_name);
3944+
return;
3945+
}
3946+
if (using_list != NULL || returning != NULL) {
3947+
CB_PENDING ("Java method call with parameters or return values");
3948+
COBC_ABORT ();
3949+
}
3950+
return;
3951+
}
3952+
39353953
/* Try to get the program referred to by prog_ref. */
39363954
program = try_get_program (prog_ref);
39373955
if (!program) {
@@ -3943,20 +3961,6 @@ cb_check_conformance (cb_tree prog_ref, cb_tree using_list,
39433961
return;
39443962
}
39453963

3946-
if (CB_LITERAL_P(prog_ref)) {
3947-
char *full_name = (char *)CB_LITERAL(prog_ref)->data;
3948-
char *class_and_method_name = full_name + 5;
3949-
char *last_dot = strrchr(class_and_method_name, '.');
3950-
if (last_dot == NULL) {
3951-
cobc_err_msg(_("Malformed Java method name '%s'"), class_and_method_name);
3952-
return;
3953-
}
3954-
if (using_list != NULL || returning != NULL) {
3955-
CB_PENDING ("Java method call with parameters or return values");
3956-
COBC_ABORT ();
3957-
}
3958-
}
3959-
39603964
/*
39613965
Check each parameter is conformant: has right type, has right
39623966
REFERENCE/VALUE phrase, has right length, etc.

0 commit comments

Comments
 (0)