Skip to content

Commit

Permalink
Merge SVN 5129
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jan 15, 2025
1 parent 4096669 commit 0cf67ee
Show file tree
Hide file tree
Showing 16 changed files with 396 additions and 283 deletions.
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ Open Plans:
of internal memory used during CALL; this can help in finding otherwise
hard to diagnose overwrite of memory and as it is only done on CALL
has a much smaller footprint than -fec=bounds (as both check different
aspects at different places it is also reasonable to use both)
aspects at different places it is also reasonable to use both);
to disable it use -fmemory-check=none or limit by -fmemory-check=pointer

** the option -g does no longer imply -fno-remove-unreachable; if you want to
keep those in you need to explicit specify this
Expand Down Expand Up @@ -396,6 +397,8 @@ Open Plans:
a coding error
-Wsuspicious-perform-thru (enabled by default) to check for PERFORM ranges
that are likely to create unwanted behaviour
-Wother now warns for suspicious reference-modification which is likely to
create out-of-bounds access at runtime

** new compiler command line option to list the known runtime exception names
and fatality `cobc --list-exceptions`
Expand Down
16 changes: 16 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@
* typeck.c (cb_emit_call): fixed skipping memory-fence generation for
EXTERNAL/BASED sub-fields

2023-07-19 Simon Sobisch <[email protected]>

* typeck.c (refmod_checks): extracted from (cb_build_identifier)
* typeck.c (refmod_checks): prevent condition-names to be reference-modified
* parser.y (class_value): improved error messages
* tree.c (cb_build_cast): set numeric category for all integer casts

2023-07-15 Simon Sobisch <[email protected]>

* typeck.c (cb_build_identifier): allow ref-mod up to identifier length
* typeck.c (cb_build_identifier): new warning for suspicious reference-
modification with start or length set to maximum and the other to var
* typeck.c (cb_build_move_literal): optimize to cb_build_move_num_zero in
more cases

2023-07-13 Simon Sobisch <[email protected]>

* pplex.l (cb_ppecho_direct, output_pending_newlines): output only up
Expand Down Expand Up @@ -252,6 +267,7 @@

* parser.y, reserved.c: added RIGHTLINE - GC extension matching LEFLINE
* parser.y: drop PENDING from OVERLINE and LEFTLINE
* tree.c (cb_build_intrinsic): refactored to get the name in a single place

2023-05-24 Simon Sobisch <[email protected]>

Expand Down
4 changes: 2 additions & 2 deletions cobc/codeoptim.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ cob_gen_optim (const enum cb_optim val)
output_storage (" const int minimal_length = zero_allowed ? 0 : 1;");
output_storage (" if (offset < 1 || length < minimal_length");
output_storage (" || offset + length - 1 > size) {");
output_storage (" cob_check_ref_mod (name, abend, zero_allowed, size, offset, length);");
output_storage (" cob_check_ref_mod_detailed (name, abend, zero_allowed, size, offset, length);");
output_storage (" }");
output_storage ("}");
output_storage ("#define cob_check_ref_mod" "\t" "cob_check_ref_mod_inline");
output_storage ("#define cob_check_ref_mod_detailed" "\t" "cob_check_ref_mod_inline");
return;

case COB_CHK_REFMOD_MIN:
Expand Down
13 changes: 7 additions & 6 deletions cobc/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -5009,12 +5009,12 @@ class_item:
}
| class_value THRU class_value
{
if (CB_TREE_CLASS ($1) != CB_CLASS_NUMERIC &&
CB_LITERAL_P ($1) && CB_LITERAL ($1)->size != 1) {
if (CB_TREE_CLASS ($1) != CB_CLASS_NUMERIC
&& CB_LITERAL_P ($1) && CB_LITERAL ($1)->size != 1) {
cb_error (_("CLASS literal with THRU must have size 1"));
}
if (CB_TREE_CLASS ($3) != CB_CLASS_NUMERIC &&
CB_LITERAL_P ($3) && CB_LITERAL ($3)->size != 1) {
if (CB_TREE_CLASS ($3) != CB_CLASS_NUMERIC
&& CB_LITERAL_P ($3) && CB_LITERAL ($3)->size != 1) {
cb_error (_("CLASS literal with THRU must have size 1"));
}
if (cb_literal_value ($1) <= cb_literal_value ($3)) {
Expand Down Expand Up @@ -19856,11 +19856,12 @@ class_value:
{
if (cb_tree_category ($1) == CB_CATEGORY_NUMERIC) {
if (CB_LITERAL ($1)->sign || CB_LITERAL ($1)->scale) {
cb_error (_("integer value expected"));
cb_error_x ($1, _("integer value expected"));
} else {
int n = cb_get_int ($1);
/* FIXME: national class has bigger "number of characters in its character set" */
if (n < 1 || n > 256) {
cb_error (_("invalid CLASS value"));
cb_error_x ($1, _("CLASS value %d outside of range for the used character set"), n);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cobc/pplex.l
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ switch_to_buffer (const int line, const char *file, const YY_BUFFER_STATE buffer

/* Reset file/line */
cb_source_line = line;
cb_source_file = cobc_plex_strdup (file);
cb_source_file = file;
fprintf (yyout, "#line %d \"%s\"\n", line, file);
/* Switch buffer */
yy_switch_to_buffer (buffer);
Expand Down
23 changes: 13 additions & 10 deletions cobc/replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void ppecho_switch (WITH_DEPTH struct cb_replacement_state *repls,
fprintf (stderr, "%sppecho_switch(%s, '%s')\n",
DEPTH, repls->name, text);
#endif
switch( repls->ppecho ){
switch (repls->ppecho) {
case CB_PPECHO_DIRECT:
#ifdef DEBUG_REPLACE
fprintf (stderr, "%s ppecho_direct('%s')\n", DEPTH, text);
Expand Down Expand Up @@ -324,9 +324,9 @@ int is_leading_or_trailing (WITH_DEPTH int leading,
const size_t src_len = strlen (src_text);
const size_t text_len = strlen(text);
int result ;
if( text_len > src_len || ( !strict && text_len == src_len ) ){
if (text_len > src_len || ( !strict && text_len == src_len )) {
int pos = leading ? 0 : text_len - src_len ;
if( strncasecmp (src_text, text+pos, src_len) ){
if (strncasecmp (src_text, text+pos, src_len)) {
result = 0;
} else {
result = 1;
Expand Down Expand Up @@ -362,7 +362,7 @@ void ppecho_leading_or_trailing (WITH_DEPTH struct cb_replacement_state *repls,

if (!leading && text_len > src_len) {
/* For TRAILING, we have to keep only the non-matched
* prefix part of the matching text */
prefix part of the matching text */
const char* remaining_text =
cobc_plex_strsub (text,
text_len - src_len);
Expand Down Expand Up @@ -503,7 +503,7 @@ void check_replace_all (WITH_DEPTH
check_replace_after_match (MORE_DEPTH repls);
} else {
const char* src_text = src->text;
if ( is_space_or_nl(src_text[0]) ){
if (is_space_or_nl(src_text[0])) {
/* skip spaces in replacement */
check_replace_all (MORE_DEPTH repls,new_text,texts,
src->next, replace_list);
Expand All @@ -520,7 +520,7 @@ void check_replace_all (WITH_DEPTH
} else {
const char* text = texts->text;
texts = texts->next;
if ( is_space_or_nl(text[0]) ){
if (is_space_or_nl(text[0])) {
/* skip spaces in texts */
check_replace_all (MORE_DEPTH repls,
new_text,
Expand Down Expand Up @@ -564,7 +564,7 @@ void check_replace_after_match (WITH_DEPTH struct cb_replacement_state *repls)
#endif
repls->current_list = NULL;
if (repls->token_queue != NULL){
if( is_space_or_nl (repls->token_queue->text[0]) ){
if (is_space_or_nl (repls->token_queue->text[0])) {
ppecho_switch (MORE_DEPTH repls,
repls->token_queue->text,
repls->token_queue->token);
Expand Down Expand Up @@ -632,6 +632,9 @@ static void add_text_to_replace (WITH_DEPTH struct cb_replacement_state *repls,
int prequeue, const char* text, const char* token
)
{
/* CHECKME: this function takes >35% of the parsing cpu instructions,
with > 18% for memory allocation - can we reduce especially the
later in cases where REPLACE / REPLACING is not active? */
#ifdef DEBUG_REPLACE_TRACE
fprintf (stderr, "%sadd_text_to_replace (%s%s, '%s')\n", DEPTH,
repls->name, prequeue ? ", PREQUEUE" : "", text);
Expand All @@ -640,7 +643,7 @@ static void add_text_to_replace (WITH_DEPTH struct cb_replacement_state *repls,

if (is_word (MORE_DEPTH text) ) {

if( repls->text_prequeue == NULL ){
if (repls->text_prequeue == NULL) {
/* a word should be kept in the prequeue */
repls->text_prequeue =
cobc_plex_strdup (text);
Expand All @@ -651,7 +654,7 @@ static void add_text_to_replace (WITH_DEPTH struct cb_replacement_state *repls,
cobc_plex_stradd (repls->text_prequeue,
text);
}
} else if ( repls->text_prequeue == NULL ){
} else if (repls->text_prequeue == NULL) {
/* not a word, and empty prequeue,
just perform replacements */
add_text_to_replace (MORE_DEPTH repls, 0, text, token);
Expand Down Expand Up @@ -724,7 +727,7 @@ struct cb_replacement_state * create_replacements (enum cb_ppecho ppecho)
s->ppecho = ppecho;

#ifdef DEBUG_REPLACE
if( ppecho == CB_PPECHO_REPLACE ){
if (ppecho == CB_PPECHO_REPLACE) {
s->name = "COPY-REPLACING";
} else {
s->name = "REPLACE";
Expand Down
Loading

0 comments on commit 0cf67ee

Please sign in to comment.