Skip to content

Commit

Permalink
Updated output_java_call and cb_check_conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
xevor11 committed Nov 12, 2024
1 parent 694669b commit 86b62c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 1 addition & 11 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -7122,7 +7122,6 @@ output_java_call(struct cb_call *p)

char* full_name = (char*)CB_LITERAL(p->name)->data; /* Assume java.prefix (enforced in `parser.y`, rule `call_body`) */
char* class_and_method_name = full_name + 5;
char *last_dot;
char *method_name;
const char *class_name;
char* mangled;
Expand All @@ -7136,14 +7135,7 @@ output_java_call(struct cb_call *p)

lookup_java_call(mangled);

last_dot = strrchr(class_and_method_name, '.');

if (last_dot == NULL) {
cobc_err_msg(_("malformed call '%s' to a Java method"), class_and_method_name);
cobc_free(mangled);
return;
}

char* last_dot = strrchr(class_and_method_name, '.');
*last_dot = '\0';
method_name = last_dot + 1;
class_name = class_and_method_name;
Expand All @@ -7156,8 +7148,6 @@ output_java_call(struct cb_call *p)
output_newline();
output_block_close();
output_exception_handling(p);

cobc_free(mangled);
}

static void
Expand Down
10 changes: 10 additions & 0 deletions cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -3943,6 +3943,16 @@ cb_check_conformance (cb_tree prog_ref, cb_tree using_list,
return;
}

if (CB_LITERAL_P(prog_ref)) {
char *full_name = (char *)CB_LITERAL(prog_ref)->data;
char *class_and_method_name = full_name + 5;
char *last_dot = strrchr(class_and_method_name, '.');
if (last_dot == NULL) {
cobc_err_msg(_("Malformed Java method name '%s'"), class_and_method_name);
return;
}
}

/*
Check each parameter is conformant: has right type, has right
REFERENCE/VALUE phrase, has right length, etc.
Expand Down

0 comments on commit 86b62c3

Please sign in to comment.