aboutsummaryrefslogtreecommitdiff
path: root/gcc/cobol
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cobol')
-rw-r--r--gcc/cobol/ChangeLog111
-rw-r--r--gcc/cobol/cbldiag.h17
-rw-r--r--gcc/cobol/cdf-copy.cc3
-rw-r--r--gcc/cobol/cdf.y18
-rw-r--r--gcc/cobol/cobol-system.h6
-rw-r--r--gcc/cobol/except.cc2
-rw-r--r--gcc/cobol/genapi.cc189
-rw-r--r--gcc/cobol/gengen.cc95
-rw-r--r--gcc/cobol/gengen.h5
-rw-r--r--gcc/cobol/genmath.cc12
-rw-r--r--gcc/cobol/genutil.cc2
-rw-r--r--gcc/cobol/lexio.cc12
-rw-r--r--gcc/cobol/parse.y102
-rw-r--r--gcc/cobol/parse_ante.h7
-rw-r--r--gcc/cobol/parse_util.h2
-rw-r--r--gcc/cobol/scan.l9
-rw-r--r--gcc/cobol/scan_ante.h36
-rw-r--r--gcc/cobol/scan_post.h2
-rw-r--r--gcc/cobol/show_parse.h49
-rw-r--r--gcc/cobol/symbols.cc6
-rw-r--r--gcc/cobol/symbols.h8
-rw-r--r--gcc/cobol/util.cc37
-rw-r--r--gcc/cobol/util.h10
23 files changed, 429 insertions, 311 deletions
diff --git a/gcc/cobol/ChangeLog b/gcc/cobol/ChangeLog
index bb8d631..1ffbed9 100644
--- a/gcc/cobol/ChangeLog
+++ b/gcc/cobol/ChangeLog
@@ -1,3 +1,114 @@
+2025-06-20 James K. Lowden <jklowden@cobolworx.com>
+
+ PR cobol/120621
+ * genapi.cc (parser_compile_ecs): Cast argument to unsigned long.
+ (parser_compile_dcls): Same.
+ (parser_division): RAII.
+ (inspect_tally): Cast argument to unsigned long.
+ * lexio.cc (cdftext::lex_open): Cast pid_t to long.
+ * parse.y: hard-code values for old versions of Bison, and message format.
+ * scan_ante.h (wait_for_the_child): Cast pid_t to long.
+
+2025-06-18 James K. Lowden <jklowden@cobolworx.com>
+
+ PR cobol/120621
+ * cbldiag.h (yyerror): Add diagnostic attributes.
+ (yywarn): Same.
+ (error_msg): Same.
+ (yyerrorvl): Same.
+ (cbl_unimplementedw): Same.
+ (cbl_unimplemented): Same.
+ (cbl_unimplemented_at): Same.
+ * cdf-copy.cc (copybook_elem_t::open_file): Supply string argument.
+ * cdf.y: Use %<%>.
+ * cobol-system.h (if): Check GCC_VERSION.
+ (ATTRIBUTE_GCOBOL_DIAG): Define.
+ * except.cc (cbl_enabled_exception_t::dump): Remove extra %s.
+ * genapi.cc (get_class_condition_string): Use acceptable message.
+ (get_bytes_needed): Same.
+ (move_tree): Same.
+ (get_string_from): Same.
+ (internal_perform_through): Same.
+ (tree_type_from_field_type): Same.
+ (is_valuable): Same.
+ (parser_logop): Same.
+ (parser_relop): Same.
+ (parser_relop_long): Same.
+ (parser_if): Same.
+ (parser_setop): Same.
+ (parser_perform_conditional): Same.
+ (parser_file_add): Same.
+ (parser_file_open): Same.
+ (parser_file_close): Same.
+ (parser_file_read): Same.
+ (parser_file_write): Same.
+ (inspect_replacing): Same.
+ (parser_sort): Same.
+ (parser_file_sort): Same.
+ (parser_file_merge): Same.
+ (create_and_call): Same.
+ (parser_bitop): Same.
+ (parser_bitwise_op): Same.
+ (hijack_for_development): Same.
+ (mh_source_is_literalN): Same.
+ (mh_dest_is_float): Same.
+ (parser_symbol_add): Same.
+ * gengen.cc (show_type): Use acceptable message.
+ (gg_find_field_in_struct): Same.
+ (gg_declare_variable): Same.
+ (gg_printf): Same.
+ (gg_fprintf): Same.
+ (gg_tack_on_function_parameters): Same.
+ (gg_define_function): Same.
+ (gg_get_function_decl): Same.
+ (gg_finalize_function): Same.
+ (gg_call_expr): Same.
+ (gg_call): Same.
+ (gg_insert_into_assembler): Define new function.
+ (gg_insert_into_assemblerf): Use gg_insert_into_assembler().
+ * gengen.h (gg_insert_into_assembler): Simpler function declaration.
+ (gg_insert_into_assemblerf): Declare new function.
+ * genmath.cc (parser_op): Use acceptable message.
+ * genutil.cc (get_binary_value): Use acceptable message.
+ * lexio.cc (parse_replacing_pair): Correct diagnostic arguments.
+ (preprocess_filter_add): Same.
+ (cdftext::open_input): Same.
+ * parse.y: Use acceptable messages.
+ * parse_ante.h (struct evaluate_elem_t): Use %<%>.
+ (is_callable): Same.
+ * parse_util.h (intrinsic_invalid_parameter): Use %qs.
+ * scan.l: Use dialect_error().
+ * scan_ante.h (numstr_of): Use %qs.
+ (scanner_token): Quote COBOL tokens in messages.
+ (scanner_parsing): Correct diagnostic message.
+ (scanner_parsing_toggle): Quote COBOL tokens in messages.
+ (scanner_parsing_pop): Same.
+ (typed_name): Use %qs.
+ * scan_post.h (prelex): Quote COBOL tokens in message.
+ * show_parse.h (CHECK_FIELD): Use acceptable message format.
+ (CHECK_LABEL): Same.
+ * symbols.cc (symbol_field_same_as): Remove extra spaces.
+ (cbl_alphabet_t::assign): Use %<%>.
+ (cbl_field_t::internalize): Quote library name in message.
+ * symbols.h (struct os_locale_t): Constify codeset.
+ (class temporaries_t): Add copy constructor.
+ (struct cbl_alphabet_t): Use acceptable message.
+ * util.cc (symbol_type_str): Use cbl_internal_error.
+ (cbl_field_type_str): Same.
+ (is_elementary): Same.
+ (cbl_field_t::report_invalid_initial_value): Use %qs.
+ (class unique_stack): Avoid %m.
+ (ydferror): Declare function with attributes.
+ (error_msg): Same.
+ (cobol_fileline_set): Use %<%>.
+ (os_locale_t): Remove use of xstrdup.
+ (cobol_parse_files): Quote C names in message.
+ (dialect_error): Use %<%>.
+ * util.h (cbl_message): Add attributes.
+ (cbl_internal_error): Same.
+ (cbl_err): Same.
+ (cbl_errx): Same.
+
2025-06-16 James K. Lowden <jklowden@cobolworx.com>
PR cobol/120621
diff --git a/gcc/cobol/cbldiag.h b/gcc/cobol/cbldiag.h
index 6b371eb..548b0f2 100644
--- a/gcc/cobol/cbldiag.h
+++ b/gcc/cobol/cbldiag.h
@@ -45,8 +45,8 @@ const char * cobol_filename();
* These are user-facing messages. They go through the gcc
* diagnostic framework and use text that can be localized.
*/
-void yyerror( const char fmt[], ... );
-bool yywarn( const char fmt[], ... );
+void yyerror( const char fmt[], ... ) ATTRIBUTE_GCOBOL_DIAG(1, 2);
+bool yywarn( const char fmt[], ... ) ATTRIBUTE_GCOBOL_DIAG(1, 2);
/* Location type. Borrowed from parse.h as generated by Bison. */
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
@@ -79,18 +79,21 @@ struct YDFLTYPE
#endif
// an error at a location, called from the parser for semantic errors
-void error_msg( const YYLTYPE& loc, const char gmsgid[], ... );
+void error_msg( const YYLTYPE& loc, const char gmsgid[], ... )
+ ATTRIBUTE_GCOBOL_DIAG(2, 3);
void dialect_error( const YYLTYPE& loc, const char term[], const char dialect[] );
// for CDF and other warnings that refer back to an earlier line
// (not in diagnostic framework yet)
-void yyerrorvl( int line, const char *filename, const char fmt[], ... );
+void yyerrorvl( int line, const char *filename, const char fmt[], ... )
+ ATTRIBUTE_PRINTF_3;
-void cbl_unimplementedw(const char *gmsgid, ...); // warning
-void cbl_unimplemented(const char *gmsgid, ...); // error
-void cbl_unimplemented_at( const YYLTYPE& loc, const char *gmsgid, ... );
+void cbl_unimplementedw(const char *gmsgid, ...) ATTRIBUTE_GCOBOL_DIAG(1, 2); // warning
+void cbl_unimplemented(const char *gmsgid, ...) ATTRIBUTE_GCOBOL_DIAG(1, 2); // error
+void cbl_unimplemented_at( const YYLTYPE& loc, const char *gmsgid, ... )
+ ATTRIBUTE_GCOBOL_DIAG(2, 3);
/*
* dbgmsg produce messages not intended for the user. They cannot be localized
diff --git a/gcc/cobol/cdf-copy.cc b/gcc/cobol/cdf-copy.cc
index f45c466..11be9b8 100644
--- a/gcc/cobol/cdf-copy.cc
+++ b/gcc/cobol/cdf-copy.cc
@@ -304,7 +304,8 @@ copybook_elem_t::open_file( const char directory[], bool literally ) {
dbgmsg("found copybook file %s", filename);
this->source.name = xstrdup(filename);
if( ! cobol_filename(this->source.name, inode_of(fd)) ) {
- error_msg(source.loc, "recursive copybook: '%s' includes itself", this->source);
+ error_msg(source.loc, "recursive copybook: '%s' includes itself",
+ this->source.name);
(void)! close(fd);
fd = -1;
}
diff --git a/gcc/cobol/cdf.y b/gcc/cobol/cdf.y
index 7e7d226..3344271 100644
--- a/gcc/cobol/cdf.y
+++ b/gcc/cobol/cdf.y
@@ -263,7 +263,7 @@ top: partials { YYACCEPT; }
YYACCEPT;
}
| copy error {
- error_msg(@error, "COPY directive must end in a '.'");
+ error_msg(@error, "COPY directive must end in a %<.%>");
YYABORT;
}
| completes { YYACCEPT; }
@@ -365,13 +365,15 @@ cdf_define: CDF_DEFINE cdf_constant NAME as cdf_expr[value] override
| CDF_DEFINE FEATURE as ON {
auto feature = cbl_gcobol_feature_t($2);
if( ! cobol_gcobol_feature_set(feature, true) ) {
- error_msg(@FEATURE, ">>DEFINE %EBCDIC-MODE is invalid within program body");
+ error_msg(@FEATURE,
+ "%<>>DEFINE %%EBCDIC-MODE%> is invalid within program body");
}
}
| CDF_DEFINE FEATURE as OFF {
auto feature = cbl_gcobol_feature_t($2);
if( ! cobol_gcobol_feature_set(feature, false) ) {
- error_msg(@FEATURE, ">>DEFINE %EBCDIC-MODE is invalid within program body");
+ error_msg(@FEATURE,
+ "%<>>DEFINE %%EBCDIC-MODE%> is invalid within program body");
}
}
;
@@ -430,7 +432,7 @@ filenames: filename {
auto inserted = $$->insert(symbol_index(symbol_elem_of($2)));
if( ! inserted.second ) {
error_msg(@2, "%s: No file-name shall be specified more than "
- " once for one exception condition", $filename->name);
+ "once for one exception condition", $filename->name);
}
}
;
@@ -517,7 +519,7 @@ cdf_relexpr: cdf_relexpr '<' cdf_expr { $$ = $1(@1) < $3(@3); }
const char *msg = $1.string?
"incommensurate comparison is FALSE: '%s' = %ld" :
"incommensurate comparison is FALSE: %ld = '%s'" ;
- error_msg(@1, msg);
+ error_msg(@1, "%s", msg);
}
}
| cdf_relexpr NE cdf_expr
@@ -531,7 +533,7 @@ cdf_relexpr: cdf_relexpr '<' cdf_expr { $$ = $1(@1) < $3(@3); }
const char *msg = $1.string?
"incommensurate comparison is FALSE: '%s' = %ld" :
"incommensurate comparison is FALSE: %ld = '%s'" ;
- error_msg(@1, msg);
+ error_msg(@1, "%s", msg);
}
}
| cdf_relexpr GE cdf_expr { $$ = $1(@1) >= $3(@3); }
@@ -567,7 +569,7 @@ cdf_factor: NAME {
| NUMSTR {
auto value = integer_literal($NUMSTR);
if( !value.second ) {
- error_msg(@1, "CDF error: parsed %s as %ld",
+ error_msg(@1, "CDF error: parsed %qs as %lld",
$NUMSTR, value.first);
YYERROR;
}
@@ -593,7 +595,7 @@ copybook_name: COPY name_one[src]
copybook.library(@lib, $lib.string);
if( -1 == copybook.open(@src, $src.string) ) {
error_msg(@src, "could not open copybook file "
- "for '%s' in '%'s'", $src.string, $lib.string);
+ "for %<%s%> in %<%s%>", $src.string, $lib.string);
YYABORT;
}
}
diff --git a/gcc/cobol/cobol-system.h b/gcc/cobol/cobol-system.h
index ff95835..828f4f5 100644
--- a/gcc/cobol/cobol-system.h
+++ b/gcc/cobol/cobol-system.h
@@ -60,4 +60,10 @@
// The following "local" #include is part of the GCC core code
#include "system.h"
+#if (CHECKING_P && GCC_VERSION >= 4001) || GCC_VERSION == BUILDING_GCC_VERSION
+#define ATTRIBUTE_GCOBOL_DIAG(m, n) __attribute__ ((__format__ (__gcc_tdiag__, m, n))) ATTRIBUTE_NONNULL(m)
+#else
+#define ATTRIBUTE_GCOBOL_DIAG(m, n) ATTRIBUTE_NONNULL(m)
+#endif
+
#endif
diff --git a/gcc/cobol/except.cc b/gcc/cobol/except.cc
index e50fa61..3e073e2 100644
--- a/gcc/cobol/except.cc
+++ b/gcc/cobol/except.cc
@@ -77,7 +77,7 @@ ec_level( ec_type_t ec ) {
void
cbl_enabled_exception_t::dump( int i ) const {
- cbl_message(2, "cbl_enabled_exception_t: %2d {%s, %s, %s, %zu}",
+ cbl_message(2, "cbl_enabled_exception_t: %2d {%s, %s, %zu}",
i,
location? "location" : " none",
ec_type_str(ec),
diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index f2a5d0e..42f1599 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -571,7 +571,7 @@ get_class_condition_string(cbl_field_t *var)
{
if( strlen(ach) > sizeof(ach) - 1000 )
{
- cbl_internal_error("Nice try, but you can't fire me. I quit!");
+ cbl_internal_error("Nice try, but you cannot fire me.");
}
// We are working with unquoted strings that contain the values 1 through
@@ -957,8 +957,8 @@ parser_compile_ecs( const std::vector<uint64_t>& ecs )
{
SHOW_PARSE_HEADER
char ach[64];
- snprintf(ach, sizeof(ach), " Size is %ld; retval is %p",
- ecs.size(), as_voidp(retval));
+ snprintf(ach, sizeof(ach), " Size is %lu; retval is %p",
+ gb4(ecs.size()), as_voidp(retval));
SHOW_PARSE_TEXT(ach)
SHOW_PARSE_END
}
@@ -966,8 +966,8 @@ parser_compile_ecs( const std::vector<uint64_t>& ecs )
{
TRACE1_HEADER
char ach[64];
- snprintf(ach, sizeof(ach), " Size is %ld; retval is %p",
- ecs.size(), as_voidp(retval));
+ snprintf(ach, sizeof(ach), " Size is %lu; retval is %p",
+ gb4(ecs.size()), as_voidp(retval));
TRACE1_TEXT_ABC("", ach, "");
TRACE1_END
}
@@ -1006,8 +1006,8 @@ parser_compile_dcls( const std::vector<uint64_t>& dcls )
{
SHOW_PARSE_HEADER
char ach[64];
- snprintf(ach, sizeof(ach), " Size is %ld; retval is %p",
- dcls.size(), as_voidp(retval));
+ snprintf(ach, sizeof(ach), " Size is %lu; retval is %p",
+ gb4(dcls.size()), as_voidp(retval));
SHOW_PARSE_TEXT(ach);
SHOW_PARSE_END
}
@@ -1015,8 +1015,8 @@ parser_compile_dcls( const std::vector<uint64_t>& dcls )
{
TRACE1_HEADER
char ach[64];
- snprintf(ach, sizeof(ach), " Size is %ld; retval is %p",
- dcls.size(), as_voidp(retval));
+ snprintf(ach, sizeof(ach), " Size is %lu; retval is %p",
+ gb4(dcls.size()), as_voidp(retval));
TRACE1_TEXT_ABC("", ach, "");
TRACE1_END
}
@@ -1756,7 +1756,7 @@ get_bytes_needed(cbl_field_t *field)
}
default:
- cbl_internal_error("%s(): Knows not the variable type %s for %s",
+ cbl_internal_error("%s: Knows not the variable type %s for %s",
__func__,
cbl_field_type_str(field->type),
field->name );
@@ -2445,10 +2445,10 @@ move_tree( cbl_field_t *dest,
if( !moved )
{
- dbgmsg("###### %10s in %s:%d\n", __func__, __FILE__, __LINE__ );
- cbl_internal_error( "I don't know how to MOVE an alphabetical string to %s(%s) \n",
- cbl_field_type_str(dest->type),
- dest->name
+ dbgmsg("%10s in %s:%d", __func__, __FILE__, __LINE__ );
+ cbl_internal_error( "I don%'t know how to MOVE an alphabetical string to %s(%s)",
+ cbl_field_type_str(dest->type),
+ dest->name
);
return;
}
@@ -2514,7 +2514,7 @@ get_string_from(cbl_field_t *field)
default:
cbl_internal_error(
- "%s(): field->type %s must be literal or alphanumeric",
+ "%s: %<field->type%> %s must be literal or alphanumeric",
__func__, cbl_field_type_str(field->type));
break;
}
@@ -3449,7 +3449,7 @@ internal_perform_through( cbl_label_t *proc_1,
pseudo_return_push(proc2, return_addr);
// Create the code that will launch the first procedure
- gg_insert_into_assembler("%s PERFORM %s THROUGH %s",
+ gg_insert_into_assemblerf("%s PERFORM %s THROUGH %s",
ASM_COMMENT_START, proc_1->name, proc_2->name);
if( !suppress_nexting )
@@ -6026,7 +6026,7 @@ tree_type_from_field_type(cbl_field_t *field, size_t &nbytes)
break;
default:
- cbl_internal_error( "%s(): Invalid field type %s:",
+ cbl_internal_error( "%s: Invalid field type %s:",
__func__,
cbl_field_type_str(field->type));
break;
@@ -6082,7 +6082,7 @@ is_valuable( cbl_field_type_t type ) {
case FldPointer:
return true;
}
- cbl_internal_error( "%s:%d: invalid symbol_type_t %d", __func__, __LINE__, type );
+ cbl_internal_error( "%s:%d: invalid %<symbol_type_t%> %d", __func__, __LINE__, type );
return false;
}
@@ -6898,7 +6898,7 @@ parser_division(cbl_division_t division,
// There are 'nusing' elements in the PROCEDURE DIVISION USING list.
- tree parameter;
+ tree parameter = NULL_TREE;
tree rt_i = gg_define_int();
for(size_t i=0; i<nusing; i++)
{
@@ -7228,20 +7228,20 @@ parser_logop( struct cbl_field_t *tgt,
if( tgt->type != FldConditional )
{
- cbl_internal_error("parser_logop() was called with variable %s on line %d"
- ", which is not a FldConditional\n",
+ cbl_internal_error("%<parser_logop()%> was called with variable %s on line %d"
+ ", which is not a FldConditional",
tgt->name, cobol_location().first_line);
}
if( a && a->type != FldConditional )
{
- cbl_internal_error("parser_logop() was called with variable %s on line %d"
- ", which is not a FldConditional\n",
+ cbl_internal_error("%<parser_logop()%> was called with variable %s on line %d"
+ ", which is not a FldConditional",
a->name, cobol_location().first_line);
}
if( b && b->type != FldConditional )
{
- cbl_internal_error("parser_logop() was called with variable %s on line %d"
- ", which is not a FldConditional\n",
+ cbl_internal_error("%<parser_logop()%> was called with variable %s on line %d"
+ ", which is not a FldConditional",
b->name, cobol_location().first_line);
}
@@ -7347,9 +7347,9 @@ parser_relop( cbl_field_t *tgt,
if( tgt->type != FldConditional )
{
- cbl_internal_error("parser_relop() was called with variable %s, "
- "which is not a FldConditional\n",
- tgt->name);
+ cbl_internal_error("%<parser_relop%> was called with variable %qs, "
+ "which is not a FldConditional",
+ tgt->name);
}
static tree comp_res = gg_define_variable(INT, "..pr_comp_res", vs_file_static);
@@ -7411,8 +7411,8 @@ parser_relop_long(cbl_field_t *tgt,
if( tgt->type != FldConditional )
{
- cbl_internal_error("parser_relop() was called with variable %s, "
- "which is not a FldConditional\n",
+ cbl_internal_error("%<parser_relop()%> was called with variable %s, "
+ "which is not a FldConditional",
tgt->name);
}
@@ -7457,8 +7457,8 @@ parser_if( struct cbl_field_t *conditional )
if( conditional->type != FldConditional )
{
- cbl_internal_error("parser_if() was called with variable %s, "
- "which is not a FldConditional\n",
+ cbl_internal_error("%<parser_if()%> was called with variable %s, "
+ "which is not a FldConditional",
conditional->name);
}
@@ -7708,20 +7708,19 @@ parser_setop( struct cbl_field_t *tgt,
integer_zero_node));
break;
default:
- dbgmsg("###### %10s in %s:%d\n", __func__, __FILE__, __LINE__ );
- cbl_internal_error(
- "###### candidate %s has unimplemented CVT_type %d(%s)\n",
- candidate->name,
- candidate->type,
- cbl_field_type_str(candidate->type));
+ dbgmsg("%10s in %s:%d", __func__, __FILE__, __LINE__ );
+ cbl_internal_error("candidate %s has unimplemented %<CVT_type%> %d(%s)",
+ candidate->name,
+ candidate->type,
+ cbl_field_type_str(candidate->type));
gcc_unreachable();
break;
}
break;
default:
- dbgmsg("###### %10s in %s:%d\n", __func__, __FILE__, __LINE__ );
- cbl_internal_error("###### unknown setop_t code %d\n", op);
+ dbgmsg("%10s in %s:%d", __func__, __FILE__, __LINE__ );
+ cbl_internal_error("unknown %<setop_t%> code %d", op);
gcc_unreachable();
break;
}
@@ -7917,7 +7916,7 @@ parser_perform_conditional( struct cbl_perform_tgt_t *tgt )
if( !(i < MAXIMUM_UNTILS) )
{
- cbl_internal_error("%s:%d: %u exceeds MAXIMUM_UNTILS of %d, line %d",
+ cbl_internal_error("%s:%d: %u exceeds %<MAXIMUM_UNTILS%> of %d, line %d",
__func__, __LINE__,
i, MAXIMUM_UNTILS, CURRENT_LINE_NUMBER);
}
@@ -9151,7 +9150,7 @@ parser_file_add(struct cbl_file_t *file)
if( !file )
{
- cbl_internal_error("%s(): called with NULL *file", __func__);
+ cbl_internal_error("%s: called with NULL *file", __func__);
gcc_assert(file);
}
@@ -9276,7 +9275,7 @@ parser_file_add(struct cbl_file_t *file)
if(file->access == file_inaccessible_e)
{
cbl_internal_error(
- "%s:%d file %s access mode is 'file_inaccessible_e' in %s",
+ "%s:%d file %s access mode is %<file_inaccessible_e%> in %s",
current_filename.back().c_str(),
CURRENT_LINE_NUMBER,
file->name,
@@ -9350,12 +9349,13 @@ parser_file_open( struct cbl_file_t *file, int mode_char )
if( !file )
{
- cbl_internal_error("parser_file_open called with NULL *file");
+ cbl_internal_error("%<parser_file_open%> called with NULL *file");
}
if( !file->var_decl_node )
{
- cbl_internal_error("parser_file_open for %s called with NULL var_decl_node", file->name);
+ cbl_internal_error("%<parser_file_open%> for %s called with NULL "
+ "%<var_decl_node%>", file->name);
}
if( mode_char == 'a' && (file->access != file_access_seq_e) )
@@ -9429,12 +9429,13 @@ parser_file_close( struct cbl_file_t *file, file_close_how_t how )
if( !file )
{
- cbl_internal_error("parser_file_close called with NULL *file");
+ cbl_internal_error("%<parser_file_close%> called with NULL *file");
}
if( !file->var_decl_node )
{
- cbl_internal_error("parser_file_close for %s called with NULL file->var_decl_node", file->name);
+ cbl_internal_error("%<parser_file_close%> for %s called with "
+ "NULL %<file->var_decl_node%>", file->name);
}
TRACE1
@@ -9498,27 +9499,29 @@ parser_file_read( struct cbl_file_t *file,
if( !file )
{
- cbl_internal_error("parser_file_read called with NULL *file");
+ cbl_internal_error("%<parser_file_read%> called with NULL *file");
}
if( !file->var_decl_node )
{
- cbl_internal_error("parser_file_read for %s called with NULL file->var_decl_node", file->name);
+ cbl_internal_error("%<parser_file_read%> for %s called with "
+ "NULL %<file->var_decl_node%>", file->name);
}
if( !file )
{
- cbl_internal_error("parser_file_read called with NULL *field");
+ cbl_internal_error("%<parser_file_read%> called with NULL *field");
}
if( !file->var_decl_node )
{
- cbl_internal_error("parser_file_read for %s called with NULL field->var_decl_node", file->name);
+ cbl_internal_error("%<parser_file_read%> for %s called with "
+ "NULL %<field->var_decl_node%>", file->name);
}
if( file->access == file_access_seq_e && where >= 0)
{
- cbl_internal_error("%s:%d file %s is RELATIVE/SEQUENTIAL, but 'where' >= 0",
+ cbl_internal_error("%s:%d file %s is RELATIVE/SEQUENTIAL, but %<where >= 0%>",
current_filename.back().c_str(),
CURRENT_LINE_NUMBER,
file->name);
@@ -9527,7 +9530,7 @@ parser_file_read( struct cbl_file_t *file,
if( file->access == file_access_rnd_e && where < 0)
{
- cbl_internal_error("%s:%d file %s is RELATIVE/RANDOM, but 'where' < 0",
+ cbl_internal_error("%s:%d file %s is RELATIVE/RANDOM, but %<where < 0%>",
current_filename.back().c_str(),
CURRENT_LINE_NUMBER,
file->name);
@@ -9615,23 +9618,23 @@ parser_file_write( cbl_file_t *file,
if( !file )
{
- cbl_internal_error("%s(): called with NULL *file", __func__);
+ cbl_internal_error("%s: called with NULL *file", __func__);
}
if( !file->var_decl_node )
{
- cbl_internal_error("%s(): for %s called with NULL file->var_decl_node",
+ cbl_internal_error("%s: for %s called with NULL %<file->var_decl_node%>",
__func__, file->name);
}
if( !file )
{
- cbl_internal_error("%s(): called with NULL *field", __func__);
+ cbl_internal_error("%s: called with NULL *field", __func__);
}
if( !file->var_decl_node )
{
- cbl_internal_error( "%s(): for %s called with NULL field->var_decl_node",
+ cbl_internal_error( "%s: for %s called with NULL %<field->var_decl_node%>",
__func__,
file->name);
}
@@ -9929,17 +9932,18 @@ inspect_tally(bool backward,
{
SHOW_PARSE_HEADER
char ach[128];
- sprintf(ach, "There are %lu identifier_2", identifier_2.size());
+ sprintf(ach, "There are %lu identifier_2", gb4(identifier_2.size()));
SHOW_PARSE_TEXT(ach);
for(size_t i=0; i<identifier_2.size(); i++)
{
SHOW_PARSE_INDENT
- sprintf(ach, "%lu: bounds: %lu", i, identifier_2[i].nbound());
+ sprintf(ach, "%lu: bounds: %lu", gb4(i), gb4(identifier_2[i].nbound()));
SHOW_PARSE_TEXT(ach);
for(size_t j=0; j<identifier_2[i].nbound(); j++)
{
SHOW_PARSE_INDENT
- sprintf(ach, " %lu: matches: %lu", j, identifier_2[i][j].matches.size());
+ sprintf(ach, " %lu: matches: %lu",
+ gb4(j), gb4(identifier_2[i][j].matches.size()));
SHOW_PARSE_TEXT(ach);
SHOW_PARSE_INDENT
@@ -10292,9 +10296,9 @@ inspect_replacing(int backward,
}
}
- //fprintf(stderr, "%s(): %ld %ld\n", __func__, int_index, n_integers);
+ //fprintf(stderr, "%s: %ld %ld\n", __func__, int_index, n_integers);
gcc_assert(int_index == n_integers);
- //fprintf(stderr, "%s(): %ld %ld\n", __func__, pcbl_index, n_resolveds);
+ //fprintf(stderr, "%s: %ld %ld\n", __func__, pcbl_index, n_resolveds);
gcc_assert(pcbl_index == n_resolveds);
// We have built up an array of integers, and an array of cbl_refer_t.
@@ -11477,7 +11481,7 @@ parser_sort(cbl_refer_t tableref,
gcc_assert(table->var_decl_node);
if( !is_table(table) )
{
- cbl_internal_error( "%s(): asked to sort %s, but it's not a table",
+ cbl_internal_error( "%s: asked to sort %s, which is not a table",
__func__,
tableref.field->name);
}
@@ -11605,7 +11609,7 @@ parser_file_sort( cbl_file_t *workfile,
else
{
// Having both or neither violates SORT syntax
- cbl_internal_error("%s(): syntax error -- both (or neither) USING "
+ cbl_internal_error("%s: syntax error: both (or neither) USING "
"and input-proc are specified",
__func__);
}
@@ -11735,7 +11739,7 @@ parser_file_sort( cbl_file_t *workfile,
}
else
{
- cbl_internal_error("%s(): syntax error -- both (or neither) GIVING "
+ cbl_internal_error("%s: syntax error: both (or neither) GIVING "
"and output-proc are specified", __func__);
}
}
@@ -12147,7 +12151,7 @@ parser_file_merge( cbl_file_t *workfile,
}
else
{
- cbl_internal_error("%s(): syntax error -- both (or neither) "
+ cbl_internal_error("%s: syntax error: both (or neither) "
"files and output-proc are specified", __func__);
}
}
@@ -12798,7 +12802,7 @@ create_and_call(size_t narg,
else
{
cbl_internal_error(
- "%s(): What in the name of Nero's fiddle are we doing here?",
+ "%s: What in the name of Nero are we doing here?",
__func__);
}
}
@@ -13038,7 +13042,7 @@ parser_bitop( struct cbl_field_t *tgt, // tgt has to be a FldConditional
if(tgt && tgt->type != FldConditional)
{
fprintf(stderr,
- "%s(): The target %s has to be a FldConditional, not %s\n",
+ "%s: The target %s has to be a FldConditional, not %s\n",
__func__,
tgt->name,
cbl_field_type_str(tgt->type));
@@ -13075,7 +13079,7 @@ parser_bitop( struct cbl_field_t *tgt, // tgt has to be a FldConditional
case bit_or_op:
case bit_xor_op:
fprintf(stderr,
- "%s(): The %s operation is not valid\n",
+ "%s: The %s operation is not valid\n",
__func__,
ops[op]);
gcc_unreachable();
@@ -13122,7 +13126,7 @@ parser_bitwise_op(struct cbl_field_t *tgt,
if( tgt && !is_valuable(tgt->type) && tgt->type != FldLiteralN)
{
fprintf(stderr,
- "%s(): The target %s has to be is_valuable, not %s\n",
+ "%s: The target %s has to be is_valuable, not %s\n",
__func__,
tgt->name,
cbl_field_type_str(tgt->type));
@@ -13136,7 +13140,7 @@ parser_bitwise_op(struct cbl_field_t *tgt,
case bit_on_op:
case bit_off_op:
fprintf(stderr,
- "%s(): The %s operation is not valid\n",
+ "%s: The %s operation is not valid\n",
__func__,
ops[op]);
gcc_unreachable();
@@ -13749,7 +13753,7 @@ hijack_for_development(const char *funcname)
// Assume that funcname is lowercase with no hyphens
enter_program_common(funcname, funcname);
parser_display_literal("You have been hijacked by a program named \"dubner\"");
- gg_insert_into_assembler("%s HIJACKED DUBNER CODE START", ASM_COMMENT_START);
+ gg_insert_into_assemblerf("%s HIJACKED DUBNER CODE START", ASM_COMMENT_START);
for(int i=0; i<10; i++)
{
@@ -13762,7 +13766,7 @@ hijack_for_development(const char *funcname)
NULL_TREE);
}
- gg_insert_into_assembler("%s HIJACKED DUBNER CODE END", ASM_COMMENT_START);
+ gg_insert_into_assemblerf("%s HIJACKED DUBNER CODE END", ASM_COMMENT_START);
gg_return(0);
}
@@ -14083,8 +14087,8 @@ mh_source_is_literalN(cbl_refer_t &destref,
default:
cbl_internal_error(
- "In parser_move(%s to %s), the move of FldLiteralN to %s "
- "hasn't been implemented",
+ "In %<parser_move(%s to %s)%>, the move of FldLiteralN to %s "
+ "is unimplemented",
sourceref.field->name,
destref.field->name,
cbl_field_type_str(destref.field->type));
@@ -14319,8 +14323,8 @@ mh_dest_is_float( cbl_refer_t &destref,
}
default:
- cbl_internal_error("In mh_dest_is_float(%s to %s), the "
- "move of %s to %s hasn't been implemented",
+ cbl_internal_error("In %<mh_dest_is_float%>(%s to %s), the "
+ "move of %s to %s is unimplemented",
sourceref.field->name,
destref.field->name,
cbl_field_type_str(sourceref.field->type),
@@ -16349,7 +16353,7 @@ parser_symbol_add(struct cbl_field_t *new_var )
{
do
{
- fprintf(stderr, "( %d ) %s():", CURRENT_LINE_NUMBER, __func__);
+ fprintf(stderr, "( %d ) %s:", CURRENT_LINE_NUMBER, __func__);
}
while(0);
@@ -16487,7 +16491,7 @@ parser_symbol_add(struct cbl_field_t *new_var )
// Make sure we have a new variable to work with.
if( !new_var )
{
- cbl_internal_error("parser_symbol_add() was called with a NULL new_var\n");
+ cbl_internal_error("%<parser_symbol_add()%> was called with a NULL %<new_var%>");
}
TRACE1
@@ -16515,7 +16519,7 @@ parser_symbol_add(struct cbl_field_t *new_var )
if( is_table(new_var) && new_var->data.capacity == 0)
{
cbl_internal_error(
- "%s(): %2.2d %s is a table, but it improperly has a capacity of zero",
+ "%s: %d %s is a table, but it improperly has a capacity of zero",
__func__,
new_var->level,
new_var->name);
@@ -16555,23 +16559,20 @@ parser_symbol_add(struct cbl_field_t *new_var )
if( ancestor == new_var )
{
- cbl_internal_error("parser_symbol_add(): %s is its own ancestor",
- new_var->name);
+ cbl_internal_error("%s: %s is its own ancestor", __func__, new_var->name);
}
if( !ancestor && (new_var->level > LEVEL01 && new_var->level <= LEVEL49 ) )
{
- cbl_internal_error("parser_symbol_add(): %2.2d %s has null ancestor",
- new_var->level,
- new_var->name);
+ cbl_internal_error("%s: %d %qs has NULL ancestor", __func__,
+ new_var->level, new_var->name);
}
// new_var's var_decl_node should be NULL at this point
if( new_var->var_decl_node )
{
- cbl_internal_error( "parser_symbol_add( %s ) improperly has a non-null "
- "var_decl_node\n",
- new_var->name);
+ cbl_internal_error( "%s(%s) improperly has a non-null "
+ "%<var_decl_node%>", __func__, new_var->name);
}
switch( new_var->type )
@@ -16765,7 +16766,7 @@ parser_symbol_add(struct cbl_field_t *new_var )
&& new_var->type != FldLiteralN
&& new_var->type != FldLiteralA )
{
- cbl_internal_error( "%s(): %2.2d %s<%s> improperly has a data.capacity of zero",
+ cbl_internal_error( "%s: %d %s<%s> improperly has a data.capacity of zero",
__func__,
new_var->level,
new_var->name,
@@ -16832,12 +16833,10 @@ parser_symbol_add(struct cbl_field_t *new_var )
if( !bytes_to_allocate )
{
- fprintf(stderr,
- "bytes_to_allocate is zero for %s (symbol number "
- HOST_SIZE_T_PRINT_DEC ")\n",
- new_var->name,
- (fmt_size_t)new_var->our_index);
- gcc_assert(bytes_to_allocate);
+ cbl_internal_error( "%<bytes_to_allocate%> is zero for %s (symbol number "
+ HOST_SIZE_T_PRINT_DEC ")",
+ new_var->name,
+ (fmt_size_t)new_var->our_index);
}
if( new_var->type == FldIndex && new_var->level == 0 )
diff --git a/gcc/cobol/gengen.cc b/gcc/cobol/gengen.cc
index a5f143c..1098225 100644
--- a/gcc/cobol/gengen.cc
+++ b/gcc/cobol/gengen.cc
@@ -360,7 +360,7 @@ show_type(tree type)
{
if( !type )
{
- cbl_internal_error("The given type is not NULL, and that's just not fair");
+ cbl_internal_error("The given type is not NULL, and that is just not fair");
}
if( DECL_P(type) )
@@ -369,7 +369,7 @@ show_type(tree type)
}
if( !TYPE_P(type) )
{
- cbl_internal_error("The given type is not a DECL or a TYPE");
+ cbl_internal_error("The given type is not a declaration or a TYPE");
}
static char ach[1024];
@@ -520,8 +520,7 @@ gg_find_field_in_struct(const tree base, const char *field_name)
if( !field_decl )
{
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
- yywarn("###### Somebody asked for the field %s.%s, which doesn't exist",
+ yywarn("Somebody asked for the field %s.%s, which does not exist",
IDENTIFIER_POINTER(DECL_NAME(base)),
field_name);
gcc_unreachable();
@@ -933,7 +932,7 @@ gg_declare_variable(tree type_decl,
// causes the storage to be allocated.
// It is routine to let the compiler assign names to stack variables. The
- // assembly code doesn't use names for variables on the stack; they are
+ // assembly code does not use names for variables on the stack; they are
// referenced by offsets to the base pointer. But static variables have to
// have names, and there are places in my code generation -- Lord only knows
// why -- where I didn't give the variables explicit names. We remedy that
@@ -2161,8 +2160,7 @@ gg_printf(const char *format_string, ...)
{
if(nargs >= ARG_LIMIT)
{
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
- yywarn("###### You *must* be joking!");
+ yywarn("You *must* be joking");
gcc_unreachable();
}
@@ -2170,10 +2168,8 @@ gg_printf(const char *format_string, ...)
{
// Warning: This test is not completely reliable, because a garbage
// byte could have a valid TREE_CODE. But it does help.
- yywarn("You nitwit!");
- yywarn("You forgot to put a NULL_TREE at the end of a "
- "gg_printf() again!");
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
+ yywarn("You forgot to put a %<NULL_TREE%> at the end of a "
+ "%<gg_printf()%> again");
gcc_unreachable();
}
@@ -2219,8 +2215,7 @@ gg_fprintf(tree fd, int nargs, const char *format_string, ...)
{
if(argc >= ARG_LIMIT)
{
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
- yywarn("###### You *must* be joking!");
+ yywarn("You *must* be joking");
gcc_unreachable();
}
@@ -2601,10 +2596,8 @@ gg_tack_on_function_parameters(tree function_decl, ...)
{
// Warning: This test is not completely reliable, because a garbage
// byte could have a valid TREE_CODE. But it does help.
- yywarn("You nitwit!");
- yywarn("You forgot to put a NULL_TREE at the end of a "
- "gg_define_function() again!");
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
+ yywarn("You forgot to put a %<NULL_TREE%> at the end of a "
+ "%<gg_define_function()%> again");
gcc_unreachable();
}
@@ -2615,8 +2608,7 @@ gg_tack_on_function_parameters(tree function_decl, ...)
nparams += 1;
if(nparams > ARG_LIMIT)
{
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
- yywarn("###### %d parameters? Really? Are you insane?",ARG_LIMIT+1);
+ yywarn("%d parameters? Really? Are you insane?",ARG_LIMIT+1);
gcc_unreachable();
}
}
@@ -2657,10 +2649,8 @@ gg_define_function(tree return_type, const char *funcname, ...)
{
// Warning: This test is not completely reliable, because a garbage
// byte could have a valid TREE_CODE. But it does help.
- yywarn("You nitwit!");
- yywarn("You forgot to put a NULL_TREE at the end of a "
- "gg_define_function() again!");
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
+ yywarn("You forgot to put a %<NULL_TREE%> at the end of a "
+ "%<gg_define_function()%> again");
gcc_unreachable();
}
@@ -2671,9 +2661,7 @@ gg_define_function(tree return_type, const char *funcname, ...)
nparams += 1;
if(nparams > ARG_LIMIT)
{
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
- yywarn("###### %d parameters? Really? Are you insane?",
- ARG_LIMIT+1);
+ yywarn("%d parameters? Really? Are you insane?", ARG_LIMIT+1);
gcc_unreachable();
}
}
@@ -2785,10 +2773,8 @@ gg_get_function_decl(tree return_type, const char *funcname, ...)
{
// Warning: This test is not completely reliable, because a garbage
// byte could have a valid TREE_CODE. But it does help.
- yywarn("You nitwit!");
- yywarn("You forgot to put a NULL_TREE at the end of a "
- "gg_define_function() again!");
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
+ yywarn("You forgot to put a %<NULL_TREE%> at the end of a "
+ "%<gg_define_function()%> again");
gcc_unreachable();
}
@@ -2799,8 +2785,7 @@ gg_get_function_decl(tree return_type, const char *funcname, ...)
nparams += 1;
if(nparams > ARG_LIMIT)
{
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
- yywarn("###### %d parameters? Really? Are you insane?",
+ yywarn("%d parameters? Really? Are you insane?",
ARG_LIMIT+1);
gcc_unreachable();
}
@@ -2909,7 +2894,7 @@ gg_finalize_function()
/* Register this function with cgraph just far enough to get it
added to our parent's nested function list. Handy, since the
- C front end doesn't have such a list. */
+ C front end does not have such a list. */
static cgraph_node *node = cgraph_node::get_create (current_function->function_decl);
gcc_assert(node);
@@ -2925,7 +2910,7 @@ gg_finalize_function()
if( gg_trans_unit.function_stack.back().context_count )
{
- cbl_internal_error("Residual context count!");
+ cbl_internal_error("Residual context count");
}
gg_trans_unit.function_stack.pop_back();
@@ -3070,8 +3055,7 @@ gg_call_expr(tree return_type, const char *function_name, ...)
{
if(nargs >= ARG_LIMIT)
{
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
- yywarn("###### You *must* be joking!");
+ yywarn("You *must* be joking");
gcc_unreachable();
}
@@ -3127,8 +3111,7 @@ gg_call(tree return_type, const char *function_name, ...)
{
if(nargs >= ARG_LIMIT)
{
- yywarn("###### %10s in %s:%d", __func__, __FILE__,__LINE__ );
- yywarn("###### You *must* be joking!");
+ yywarn("You *must* be joking");
gcc_unreachable();
}
@@ -3425,7 +3408,27 @@ gg_trans_unit_var_decl(const char *var_name)
}
void
-gg_insert_into_assembler(const char *format, ...)
+gg_insert_into_assembler(const char ach[])
+ {
+ if( !optimize )
+ {
+ // Create the required generic tag
+ tree asm_expr = build5_loc( location_from_lineno(),
+ ASM_EXPR,
+ VOID,
+ build_string(strlen(ach), ach),
+ NULL_TREE,
+ NULL_TREE,
+ NULL_TREE,
+ NULL_TREE);
+
+ // And insert it as a statement
+ gg_append_statement(asm_expr);
+ }
+ }
+
+void
+gg_insert_into_assemblerf(const char *format, ...)
{
// Temporarily defeat all ASM_EXPR for optimized code per PR119214
// The correct solution using LABEL_DECL is forthcoming
@@ -3444,18 +3447,6 @@ gg_insert_into_assembler(const char *format, ...)
vsnprintf(ach, sizeof(ach), format, ap);
va_end(ap);
- // Create the required generic tag
- tree asm_expr = build5_loc( location_from_lineno(),
- ASM_EXPR,
- VOID,
- build_string(strlen(ach), ach),
- NULL_TREE,
- NULL_TREE,
- NULL_TREE,
- NULL_TREE);
- //SET_EXPR_LOCATION (asm_expr, UNKNOWN_LOCATION);
-
- // And insert it as a statement
- gg_append_statement(asm_expr);
+ gg_insert_into_assembler(ach);
}
}
diff --git a/gcc/cobol/gengen.h b/gcc/cobol/gengen.h
index 8c1bc8d..15c2a6b 100644
--- a/gcc/cobol/gengen.h
+++ b/gcc/cobol/gengen.h
@@ -539,6 +539,9 @@ extern tree gg_trans_unit_var_decl(const char *var_name);
tree gg_open(tree char_star_A, tree int_B);
tree gg_close(tree int_A);
tree gg_get_indirect_reference(tree pointer, tree offset);
-void gg_insert_into_assembler(const char *format, ...);
+
+void gg_insert_into_assembler(const char ach[]);
+void gg_insert_into_assemblerf(const char *format, ...) ATTRIBUTE_PRINTF_1;
+
void gg_modify_function_type(tree function_decl, tree return_type);
#endif
diff --git a/gcc/cobol/genmath.cc b/gcc/cobol/genmath.cc
index bf3885b..0a1c12d 100644
--- a/gcc/cobol/genmath.cc
+++ b/gcc/cobol/genmath.cc
@@ -1383,12 +1383,12 @@ parser_op( struct cbl_refer_t cref,
break;
}
default:
- cbl_internal_error( "parser_op() doesn't know how to "
- "evaluate \"%s = %s %c %s\"\n",
- cref.field->name,
- aref.field->name,
- op,
- bref.field->name);
+ cbl_internal_error( "%<parser_op()%> doesn%'t know how to "
+ "evaluate %<%s = %s %c %s%>",
+ cref.field->name,
+ aref.field->name,
+ op,
+ bref.field->name);
break;
}
}
diff --git a/gcc/cobol/genutil.cc b/gcc/cobol/genutil.cc
index 8ec7a78..1d921a3 100644
--- a/gcc/cobol/genutil.cc
+++ b/gcc/cobol/genutil.cc
@@ -737,7 +737,7 @@ get_binary_value( tree value,
{
if( SCALAR_FLOAT_TYPE_P(value) )
{
- cbl_internal_error("Can't get float value from %s", field->name);
+ cbl_internal_error("cannot get %<float%> value from %s", field->name);
}
else
{
diff --git a/gcc/cobol/lexio.cc b/gcc/cobol/lexio.cc
index 888cce1..5b6000d 100644
--- a/gcc/cobol/lexio.cc
+++ b/gcc/cobol/lexio.cc
@@ -745,7 +745,7 @@ parse_replacing_pair( const char *stmt, const char *estmt ) {
}
}
if( pair.stmt.p ) {
- yywarn("CDF syntax error '%*s'", (int)pair.stmt.size(), pair.stmt.p);
+ yywarn("CDF syntax error '%.*s'", (int)pair.stmt.size(), pair.stmt.p);
}
else {
// This eliminated a compiler warning about "format-overflow"
@@ -1413,7 +1413,7 @@ preprocess_filter_add( const char input[] ) {
auto filename = find_filter(filter.c_str());
if( !filename ) {
- yywarn("preprocessor '%s/%s' not found", getcwd(NULL, 0), filter);
+ yywarn("preprocessor '%s/%s' not found", getcwd(NULL, 0), filter.c_str());
return false;
}
preprocessor_filters.push_back( std::make_pair(xstrdup(filename), options) );
@@ -1524,11 +1524,11 @@ cdftext::lex_open( const char filename[] ) {
int status;
auto kid = wait(&status);
gcc_assert(pid == kid);
- if( kid == -1 ) cbl_err( "failed waiting for pid %d", pid);
+ if( kid == -1 ) cbl_err( "failed waiting for pid %ld", static_cast<long>(pid));
if( WIFSIGNALED(status) ) {
- cbl_errx( "%s pid %d terminated by %s",
- filter, kid, strsignal(WTERMSIG(status)) );
+ cbl_errx( "%s pid %ld terminated by %s",
+ filter, static_cast<long>(kid), strsignal(WTERMSIG(status)) );
}
if( WIFEXITED(status) ) {
if( (status = WEXITSTATUS(status)) != 0 ) {
@@ -1546,7 +1546,7 @@ int
cdftext::open_input( const char filename[] ) {
int fd = open(filename, O_RDONLY);
if( fd == -1 ) {
- dbgmsg( "could not open '%s': %m", filename );
+ dbgmsg( "could not open '%s': %s", filename, xstrerror(errno) );
}
verbose_file_reader = NULL != getenv("GCOBOL_TEMPDIR");
diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index 3afa20f..f0faaa4 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -1482,7 +1482,7 @@ program_id: PROGRAM_ID dot namestr[name] program_as program_attrs[attr] dot
const char *name = string_of($name);
parser_enter_program( name, false, &main_error );
if( main_error ) {
- error_msg(@name, "PROGRAM-ID 'main' is invalid with -main option");
+ error_msg(@name, "PROGRAM-ID 'main' is invalid with %<-main%> option");
YYERROR;
}
@@ -1518,7 +1518,8 @@ function_id: FUNCTION '.' NAME program_as program_attrs[attr] '.'
int main_error = 0;
parser_enter_program( $NAME, true, &main_error );
if( main_error ) {
- error_msg(@NAME, "FUNCTION-ID 'main' is invalid with -main option");
+ error_msg(@NAME, "FUNCTION-ID %<main%> is invalid "
+ "with %<-main%> option");
YYERROR;
}
if( symbols_begin() == symbols_end() ) {
@@ -1589,7 +1590,7 @@ opt_binary: FLOAT_BINARY default_kw is HIGH_ORDER_LEFT
{
cbl_unimplementedw("HIGH-ORDER-LEFT was ignored");
if( ! current.option_binary(cbl_options_t::high_order_left_e) ) {
- error_msg(@3, "unable to set HIGH_ORDER_LEFT");
+ error_msg(@3, "unable to set %<HIGH_ORDER_LEFT%>");
}
}
| FLOAT_BINARY default_kw is HIGH_ORDER_RIGHT[opt]
@@ -2520,7 +2521,7 @@ dev_mnemonic: device_name is NAME
{
auto p = cmd_or_env_special_of($device);
if( !p ) {
- error_msg(@device, "%s is not a device name");
+ error_msg(@device, "%s is not a device name", $device);
YYERROR;
}
@@ -2646,7 +2647,7 @@ alphabet_seq: alphabet_lit[low]
alphabet_etc: alphabet_lit
{
if( $1.len > 1 ) {
- error_msg(@1, "'%c' can be only a single letter", $1.data);
+ error_msg(@1, "%qs can be only a single letter", $1.data);
YYERROR;
}
$$ = (unsigned char)$1.data[0];
@@ -2912,7 +2913,7 @@ fd_clause: record_desc
f->varying_size.explicitly = f->varies();
if( f->varying_size.max != 0 ) {
if( !(f->varying_size.min <= f->varying_size.max) ) {
- error_msg(@1, "%zu must be <= %zu",
+ error_msg(@1, "%zu must be less than or equal to %zu",
f->varying_size.min, f->varying_size.max);
YYERROR;
}
@@ -2988,7 +2989,7 @@ rec_contains: NUMSTR[min] {
}
$$.max = n;
if( !($$.min < $$.max) ) {
- error_msg(@max, "FROM (%xz) must be less than TO (%zu)",
+ error_msg(@max, "FROM (%zu) must be less than TO (%zu)",
$$.min, $$.max);
YYERROR;
}
@@ -3184,7 +3185,7 @@ field: cdf
}
initial = string_of(field.data.value_of());
if( !initial ) {
- error_msg(@1, xstrerror(errno));
+ error_msg(@1, "could not convert value to string");
YYERROR;
}
char decimal = symbol_decimal_point();
@@ -3638,7 +3639,7 @@ data_descr1: level_name
}
if( field_index($thru) <= field_index($orig) ) {
error_msg(@orig, "cannot RENAME %s %s THRU %s %s "
- "because they're in the wrong order",
+ "because they are in the wrong order",
$orig->level_str(), name_of($orig),
$thru->level_str(), name_of($thru));
YYERROR;
@@ -3680,7 +3681,7 @@ data_descr1: level_name
case FldNumericEdited:
if( $field->has_attr(signable_e) ) {
error_msg(@2, "%s has 'S' in PICTURE, cannot be BLANK WHEN ZERO",
- $field->name, cbl_field_type_str($field->type) );
+ $field->name );
}
break;
default:
@@ -3891,9 +3892,8 @@ data_clauses: data_clause
auto redefined = symbol_redefines(field);
if( redefined && redefined->type == FldPointer ) {
if( yydebug ) {
- yywarn("expanding %s size from %u bytes to "
- HOST_WIDE_INT_PRINT " "
- "because it redefines %s with USAGE POINTER",
+ yywarn("expanding %s size from %u bytes to %wd "
+ "because it redefines %s with %<USAGE POINTER%>",
field->name, field->size(),
int_size_in_bytes(ptr_type_node),
redefined->name);
@@ -3986,7 +3986,7 @@ picture_clause: PIC signed nps[fore] nines nps[aft]
field->data.capacity = type_capacity(field->type, $4);
field->data.digits = $4;
if( long(field->data.digits) != $4 ) {
- error_msg(@2, "indicated size would be %ld bytes, "
+ error_msg(@2, "indicated size would be %d bytes, "
"maximum data item size is %u",
$4, UINT32_MAX);
}
@@ -4056,7 +4056,7 @@ picture_clause: PIC signed nps[fore] nines nps[aft]
(dialect_gnu() || dialect_mf()) )
{ // PIC X COMP-X or COMP-9
if( ! field->has_attr(all_x_e) ) {
- error_msg(@2, "COMP PICTURE requires all X's or all 9's");
+ error_msg(@2, "COMP PICTURE requires all X%'s or all 9%'s");
YYERROR;
}
} else {
@@ -4091,7 +4091,7 @@ picture_clause: PIC signed nps[fore] nines nps[aft]
}
ERROR_IF_CAPACITY(@PIC, field);
if( !is_numeric_edited($picture) ) {
- error_msg(@picture, numed_message);
+ error_msg(@picture, "%s", numed_message);
YYERROR;
}
field->data.picture = $picture;
@@ -4170,7 +4170,7 @@ alphanum_part: ALNUM[picture] count
$$.nbyte += count; // AX9(3) has count 5
}
if( count < 0 ) {
- error_msg(@2, "PICTURE count '(%d)' is negative", count );
+ error_msg(@2, "PICTURE count %<(%d)%> is negative", count );
YYERROR;
}
}
@@ -4189,7 +4189,7 @@ nine: %empty { $$ = 0; }
{
$$ = $1;
if( $$ == 0 ) {
- error_msg(@1, "'(0)' invalid in PICTURE (ISO 2023 13.18.40.3)");
+ error_msg(@1, "%<(0)%> invalid in PICTURE (ISO 2023 13.18.40.3)");
}
}
;
@@ -4203,14 +4203,14 @@ count: %empty { $$ = 0; }
REAL_VALUE_TYPE rn = numstr2i($NUMSTR.string, $NUMSTR.radix);
$$ = real_to_integer (&rn);
if( $$ == 0 ) {
- error_msg(@2, "'(0)' invalid in PICTURE (ISO 2023 13.18.40.3)");
+ error_msg(@2, "%<0%> invalid in PICTURE (ISO 2023 13.18.40.3)");
}
}
| '(' NAME ')'
{
auto value = cdf_value($NAME);
if( ! (value && value->is_numeric()) ) {
- error_msg(@NAME, "PICTURE '(%s)' requires a CONSTANT value", $NAME );
+ error_msg(@NAME, "PICTURE %qs requires a CONSTANT value", $NAME );
YYERROR;
}
int nmsg = 0;
@@ -4223,13 +4223,13 @@ count: %empty { $$ = 0; }
if( !real_identical (TREE_REAL_CST_PTR (field->data.value_of()),
&vi) ) {
nmsg++;
- error_msg(@NAME, "invalid PICTURE count '(%s)'",
+ error_msg(@NAME, "invalid PICTURE count %<(%s)%>",
field->data.initial );
}
}
$$ = value->as_number();
if( $$ <= 0 && !nmsg) {
- error_msg(@NAME, "invalid PICTURE count '(%s)'", $NAME );
+ error_msg(@NAME, "invalid PICTURE count %<(%s)%>", $NAME );
}
}
;
@@ -4974,12 +4974,11 @@ statements: statement { $$ = $1; }
statement: error {
if( current.declarative_section_name() ) {
- error_msg(@1, "missing END DECLARATIVES or SECTION name",
- nparse_error);
+ error_msg(@1, "missing END DECLARATIVES or SECTION name");
YYABORT;
}
if( max_errors_exceeded(nparse_error) ) {
- error_msg(@1, "max errors %d reached", nparse_error);
+ error_msg(@1, "max errors %zu reached", nparse_error);
YYABORT;
}
}
@@ -5692,7 +5691,8 @@ end_program: end_program1[end] '.'
gcc_unreachable();
}
if( !matches ) {
- error_msg(@end, "END %s %s' does not match IDENTIFICATION DIVISION '%s'",
+ error_msg(@end, "END %s %s does not match "
+ "%<IDENTIFICATION DIVISION %s%>",
token_name, name, prog->name);
YYERROR;
}
@@ -5723,9 +5723,9 @@ end_program: end_program1[end] '.'
token_name = "FUNCTION";
break;
default:
- cbl_internal_error( "END token invalid");
+ cbl_internal_error( "%<END%> token invalid");
}
- error_msg(@end, "END %s requires NAME before '.'", token_name);
+ error_msg(@end, "%<END%> %s requires %<NAME%> before %<.%>", token_name);
YYERROR;
}
;
@@ -6776,7 +6776,7 @@ move: MOVE scalar TO move_tgts[tgts]
{
statement_begin(@1, MOVE);
if( $scalar->field->type == FldIndex ) {
- error_msg(@1, "'%s' cannot be MOVEd because it's an INDEX",
+ error_msg(@1, "%qs cannot be MOVEd because it is an %<INDEX%>",
name_of($scalar->field) );
YYERROR;
}
@@ -7168,20 +7168,20 @@ section_kw: SECTION
{
if( $1 ) {
if( *$1 == '-' ) {
- error_msg(@1, "SECTION segment %<%s%> is negative", $1);
+ error_msg(@1, "SECTION segment %qs is negative", $1);
} else {
if( dialect_ibm() ) {
int sectno;
sscanf($1, "%d", &sectno);
if( ! (0 <= sectno && sectno <= 99) ) {
- error_msg(@1, "SECTION segment %<%s%> must be 0-99", $1);
+ error_msg(@1, "SECTION segment %qs must be 0-99", $1);
} else {
if(false) { // stand-in for warning, someday.
- yywarn("SECTION segment %<%s%> was ignored", $1);
+ yywarn("SECTION segment %qs was ignored", $1);
}
}
} else {
- cbl_unimplemented("SECTION segment %<%s%> is not ISO syntax", $1);
+ cbl_unimplemented("SECTION segment %qs is not ISO syntax", $1);
}
}
}
@@ -7932,7 +7932,7 @@ raise: RAISE EXCEPTION NAME
"EXCEPTION CONDITION: %s", $NAME);
YYERROR;
}
- cbl_unimplemented("RAISE <EXCEPTION OBJECT>");
+ cbl_unimplemented("RAISE %<EXCEPTION OBJECT%>");
YYERROR;
}
;
@@ -8009,7 +8009,7 @@ read_body: NAME read_next read_into read_key
YYERROR;
}
if( $read_key->field && $read_next < 0 ) {
- error_msg(@1, "cannot read NEXT with KEY", $$->name);
+ error_msg(@1, "cannot read NEXT with KEY %qs", $$->name);
YYERROR;
}
@@ -8803,7 +8803,7 @@ search_term: scalar[key] '=' search_expr[sarg]
}
if( dimensions($key->field) < $key->nsubscript() ) {
error_msg(@1, "too many subscripts: "
- "%zu for table of %zu dimensions",
+ "%u for table of %zu dimensions",
$key->nsubscript(), dimensions($key->field) );
YYERROR;
}
@@ -9137,7 +9137,7 @@ inspect: INSPECT backward inspected TALLYING tallies
if( is_literal(match) && is_literal(replace) ) {
if( !$match->all && !$replace_oper->all) {
if( match->data.capacity != replace->data.capacity ) {
- error_msg(@match, "'%s', size %u NOT EQUAL '%s', size %u",
+ error_msg(@match, "%qs, size %u NOT EQUAL %qs, size %u",
nice_name_of(match), match->data.capacity,
nice_name_of(replace), replace->data.capacity);
YYERROR;
@@ -10212,8 +10212,8 @@ intrinsic: function_udf
args.data());
if( p != NULL ) {
auto loc = symbol_field_location(field_index(p->field));
- error_msg(loc, "FUNCTION %s has "
- "inconsistent parameter type %zu ('%s')",
+ error_msg(loc, "FUNCTION %qs has "
+ "inconsistent parameter type %zu (%qs)",
keyword_str($1), p - args.data(), name_of(p->field) );
YYERROR;
}
@@ -10290,7 +10290,7 @@ intrinsic: function_udf
location_set(@1);
$$ = new_alphanumeric("FIND-STRING");
/* auto r1 = new_reference(new_literal(strlen($r1), $r1, quoted_e)); */
- cbl_unimplemented("FIND_STRING");
+ cbl_unimplemented("%<FIND_STRING%>");
/* if( ! intrinsic_call_4($$, FIND_STRING, r1, $r2) ) YYERROR; */
}
@@ -10757,7 +10757,7 @@ numval_locale: %empty {
$$.arg2 = cbl_refer_t::empty();
}
| LOCALE NAME { $$.is_locale = true; $$.arg2 = NULL;
- cbl_unimplemented("NUMVAL_C LOCALE"); YYERROR;
+ cbl_unimplemented("%<NUMVAL_C LOCALE%>"); YYERROR;
}
| varg { $$.is_locale = false; $$.arg2 = $1; }
;
@@ -11409,8 +11409,8 @@ keyword_str( int token ) {
switch( token ) {
case YYEOF: return "YYEOF";
case YYEMPTY: return "YYEMPTY";
- case YYerror: return "YYerror";
- case YYUNDEF: return "invalid token";
+ case 256: return "YYerror";
+ case 257: return "invalid token"; // YYUNDEF
}
if( token < 256 ) {
@@ -11541,7 +11541,7 @@ relop_invert(relop_t op) {
case ge_op: return lt_op;
case gt_op: return le_op;
}
- cbl_errx( "%s:%d: invalid relop_t %d", __func__, __LINE__, op);
+ cbl_internal_error("%s:%d: invalid %<relop_t%> %d", __func__, __LINE__, op);
return relop_t(0); // not reached
}
@@ -11834,7 +11834,7 @@ current_t::udf_args_valid( const cbl_label_t *L,
auto tgt = cbl_field_of(symbol_at(udf.linkage_fields.at(i).isym));
if( ! valid_move(tgt, arg.field) ) {
auto loc = symbol_field_location(field_index(arg.field));
- error_msg(loc, "FUNCTION %s arg %zu, '%s' cannot be passed to %s, type %s",
+ error_msg(loc, "FUNCTION %s argument %zu, '%s' cannot be passed to %s, type %s",
L->name, i, arg.field->pretty_name(),
tgt->pretty_name(), 3 + cbl_field_type_str(tgt->type) );
return false;
@@ -12032,7 +12032,7 @@ struct stringify_src_t : public cbl_string_src_t {
protected:
static void dump_input( const cbl_refer_t& refer ) {
- yywarn( "%s:\t%s", __func__, field_str(refer.field) );
+ yywarn( "%s: %s", __func__, field_str(refer.field) );
}
};
@@ -12341,7 +12341,7 @@ numstr2i( const char input[], radix_t radix ) {
case boolean_e:
for( const char *p = input; *p != '\0'; p++ ) {
if( ssize_t(8 * sizeof(integer) - 1) < p - input ) {
- yywarn("'%s' was accepted as %d", input, integer);
+ yywarn("'%s' was accepted as %zu", input, integer);
break;
}
switch(*p) {
@@ -12351,7 +12351,7 @@ numstr2i( const char input[], radix_t radix ) {
integer |= ((*p) == '0' ? 0 : 1);
break;
default:
- yywarn("'%s' was accepted as %d", input, integer);
+ yywarn("'%s' was accepted as %zu", input, integer);
break;
}
}
@@ -12359,7 +12359,7 @@ numstr2i( const char input[], radix_t radix ) {
return output;
}
if( erc == -1 ) {
- yywarn("'%s' was accepted as %lld", input, output);
+ yywarn("'%s' was accepted as %zu", input, integer);
}
return output;
}
@@ -12982,7 +12982,7 @@ literal_attr( const char prefix[] ) {
}
// must be [BN]X
- cbl_internal_error("'%s': invalid literal prefix", prefix);
+ cbl_internal_error("invalid literal prefix: %qs", prefix);
gcc_unreachable();
return none_e;
}
@@ -13141,7 +13141,7 @@ literal_subscripts_valid( YYLTYPE loc, const cbl_refer_t& name ) {
// X(0): subscript 1 of for out of range for 02 X OCCURS 4 to 6
error_msg(loc, "%s(%s): subscript %zu out of range "
- "for %s %s OCCURS %lu%s",
+ "for %s %s OCCURS %zu%s",
oob->name, subscript_names.c_str(), 1 + isub,
oob->level_str(), oob->name,
oob->occurs.bounds.lower, upper_phrase );
diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h
index ffb4c98..8194614 100644
--- a/gcc/cobol/parse_ante.h
+++ b/gcc/cobol/parse_ante.h
@@ -335,7 +335,7 @@ struct evaluate_elem_t {
label.line = yylineno;
if( -1 == snprintf(label.name, sizeof(label.name),
"%.*s_%d", (int)sizeof(label.name)-6, skel, yylineno) ) {
- yyerror("could not create unique label '%s_%d' because it is too long",
+ yyerror("could not create unique label %<%s_%d%> because it is too long",
skel, yylineno);
}
}
@@ -2116,7 +2116,7 @@ static class current_t {
if( ! dialect_ibm() ) {
error_msg(loc,
"Per ISO a program with DECLARATIVES must begin with a SECTION, "
- "requires -dialect ibm");
+ "requires %<-dialect ibm%>");
}
}
}
@@ -2558,7 +2558,8 @@ is_callable( const cbl_field_t *field ) {
case FldPointer:
return true;
}
- cbl_internal_error( "%s:%d: invalid symbol_type_t %d", __func__, __LINE__, field->type );
+ cbl_internal_error( "%s:%d: invalid %<symbol_type_t%> %d",
+ __func__, __LINE__, field->type );
return false;
}
diff --git a/gcc/cobol/parse_util.h b/gcc/cobol/parse_util.h
index 11b86a3..006cea7 100644
--- a/gcc/cobol/parse_util.h
+++ b/gcc/cobol/parse_util.h
@@ -348,7 +348,7 @@ intrinsic_invalid_parameter( int token,
return token == descr.token;
} );
if( p == function_descrs_end ) {
- cbl_internal_error( "%s: intrinsic function %s not found",
+ cbl_internal_error( "%s: intrinsic function %qs not found",
__func__, keyword_str(token) );
}
diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l
index 52a0b94..9b586e9 100644
--- a/gcc/cobol/scan.l
+++ b/gcc/cobol/scan.l
@@ -982,7 +982,7 @@ USE({SPC}FOR)? { return USE; }
BINARY-LONG { return bcomputable(FldNumericBin5, 4); }
BINARY-DOUBLE { return bcomputable(FldNumericBin5, 8); }
BINARY-LONG-LONG { if( ! dialect_mf() ) {
- error_msg(yylloc, "%s requires -dialect mf", yytext);
+ dialect_error(yylloc, yytext, "mf");
}
return bcomputable(FldNumericBin5, 8);
}
@@ -993,7 +993,7 @@ USE({SPC}FOR)? { return USE; }
FLOAT-BINARY-32 { return ucomputable(FldFloat, 4); }
FLOAT-BINARY-64 { return ucomputable(FldFloat, 8); }
FLOAT-BINARY-128 { return ucomputable(FldFloat, 16); }
- FLOAT-DECIMAL-(16|34) { not_implemented("USAGE type: FLOAT_DECIMAL");
+ FLOAT-DECIMAL-(16|34) { not_implemented("USAGE type: %<FLOAT_DECIMAL%>");
return FLOAT_DECIMAL; // causes syntax error
}
/* 21) The representation and length of a data item described with USAGE
@@ -1019,7 +1019,7 @@ USE({SPC}FOR)? { return USE; }
POINTER { yylval.field_attr = none_e; return POINTER; }
PROCEDURE-POINTER { if( dialect_gcc() ) {
- error_msg(yylloc, "%s requires -dialect ibm or mf", yytext);
+ dialect_error(yylloc, yytext, "ibm or mf");
}
yylval.field_attr = prog_ptr_e;
return POINTER; // return it anyway
@@ -2482,10 +2482,9 @@ BASIS { yy_push_state(basis); return BASIS; }
<<EOF>> {
if( YY_START == quoted1 || YY_START == quoted2 ) {
- error_msg(yylloc, "syntax error: unterminated string '%s'",
+ error_msg(yylloc, "syntax error: unterminated string %<%s%>",
tmpstring);
return NO_CONDITION;
- cbl_internal_error("");
}
yypop_buffer_state();
diff --git a/gcc/cobol/scan_ante.h b/gcc/cobol/scan_ante.h
index 21e89e4..96b688e 100644
--- a/gcc/cobol/scan_ante.h
+++ b/gcc/cobol/scan_ante.h
@@ -159,11 +159,11 @@ numstr_of( const char string[], radix_t radix = decimal_e ) {
// exponent is implementor-defined." (We allow 9999.)
nx = std::count_if(p, eoinput, fisdigit);
if( 4 < nx ) {
- error_msg(yylloc, "exponent %s more than 4 digits", ++p);
+ error_msg(yylloc, "exponent %qs more than 4 digits", ++p);
return NO_CONDITION;
}
if( eoinput != std::find(p, eoinput, symbol_decimal_point()) ) {
- error_msg(yylloc, "exponent includes decimal point", ++p);
+ error_msg(yylloc, "exponent %qs includes decimal point", ++p);
return NO_CONDITION;
}
@@ -187,7 +187,7 @@ numstr_of( const char string[], radix_t radix = decimal_e ) {
}
}
if( 1 < std::count(input, eoinput, symbol_decimal_point()) ) {
- error_msg(yylloc, "invalid numeric literal", ++p);
+ error_msg(yylloc, "invalid numeric literal %qs", ++p);
return NO_CONDITION;
}
@@ -295,7 +295,7 @@ static class parsing_status_t : public std::stack<cdf_status_t> {
void splat() const {
int i=0;
for( const auto& status : c ) {
- yywarn( "%4d\t%s", ++i, status.str() );
+ yywarn( "%d %s", ++i, status.str() );
}
}
} parsing;
@@ -305,7 +305,7 @@ void field_done() { orig_picture[0] = '\0'; parsing.need_level(true); }
static int scanner_token() {
if( parsing.empty() ) {
- error_msg(yylloc, ">>ELSE or >>END-IF without >>IF");
+ error_msg(yylloc, "%<>>ELSE%> or %<>>END-IF%> without %<>>IF%>");
return NO_CONDITION;
}
return parsing.top().token;
@@ -317,33 +317,32 @@ bool scanner_normal() { return parsing.normal(); }
void scanner_parsing( int token, bool tf ) {
parsing.push( cdf_status_t(token, tf) );
if( yydebug ) {
- yywarn("%10s: parsing now %5s, depth %lu",
- keyword_str(token), boolalpha(parsing.on()),
- gb4(parsing.size()));
+ yywarn("%s: parsing now %s, depth %zu",
+ keyword_str(token), boolalpha(parsing.on()), parsing.size());
parsing.splat();
}
}
void scanner_parsing_toggle() {
if( parsing.empty() ) {
- error_msg(yylloc, ">>ELSE without >>IF");
+ error_msg(yylloc, "%<>>ELSE%> without %<>>IF%>");
return;
}
parsing.top().toggle();
if( yydebug ) {
- yywarn("%10s: parsing now %5s",
+ yywarn("%s: parsing now %s",
keyword_str(CDF_ELSE), boolalpha(parsing.on()));
}
}
void scanner_parsing_pop() {
if( parsing.empty() ) {
- error_msg(yylloc, ">>END-IF without >>IF");
+ error_msg(yylloc, "%<>>END-IF%> without %<>>IF%>");
return;
}
parsing.pop();
if( yydebug ) {
- yywarn("%10s: parsing now %5s, depth %lu",
+ yywarn("%s: parsing now %s, depth %zu",
keyword_str(CDF_END_IF), boolalpha(parsing.on()),
- gb4(parsing.size()));
+ parsing.size());
parsing.splat();
}
}
@@ -792,7 +791,7 @@ typed_name( const char name[] ) {
return cbl_field_of(e)->level == 88? NAME88 : CLASS_NAME;
break;
default:
- yywarn("%s:%d: invalid symbol type %s for symbol \"%s\"",
+ yywarn("%s:%d: invalid symbol type %s for symbol %qs",
__func__, __LINE__, cbl_field_type_str(type), name);
return NAME;
}
@@ -825,17 +824,20 @@ wait_for_the_child(void) {
}
if( WIFSIGNALED(status) ) {
- yywarn( "process %d terminated by %s", pid, strsignal(WTERMSIG(status)) );
+ yywarn( "process %ld terminated by %s",
+ static_cast<long>(pid), strsignal(WTERMSIG(status)) );
return false;
}
if( WIFEXITED(status) ) {
if( WEXITSTATUS(status) != 0 ) {
- yywarn("process %d exited with status %d", pid, status);
+ yywarn("process %ld exited with status %d",
+ static_cast<long>(pid), status);
return false;
}
}
if( yy_flex_debug ) {
- yywarn("process %d exited with status %d", pid, status);
+ yywarn("process %ld exited with status %d",
+ static_cast<long>(pid), status);
}
return true;
}
diff --git a/gcc/cobol/scan_post.h b/gcc/cobol/scan_post.h
index 385ea67..a273da9 100644
--- a/gcc/cobol/scan_post.h
+++ b/gcc/cobol/scan_post.h
@@ -297,7 +297,7 @@ prelex() {
token = LEVEL;
break;
case YDF_NUMBER:
- if( yy_flex_debug ) yywarn("final token is YDF_NUMBER");
+ if( yy_flex_debug ) yywarn("final token is %<YDF_NUMBER%>");
yylval.number = ydflval.number;
token = LEVEL;
break;
diff --git a/gcc/cobol/show_parse.h b/gcc/cobol/show_parse.h
index d417af3..db24807 100644
--- a/gcc/cobol/show_parse.h
+++ b/gcc/cobol/show_parse.h
@@ -424,30 +424,31 @@ extern bool cursor_at_sol;
// Use CHECK_FIELD when a should be non-null, and a->var_decl_node also should
// by non-null:
-#define CHECK_FIELD(a) \
- do{ \
- if(!a) \
- { \
- yywarn("%s(): parameter " #a " is NULL", __func__); \
- gcc_unreachable(); \
- } \
- if( !a->var_decl_node && a->type != FldConditional && a->type != FldLiteralA) \
- { \
- yywarn("%s() parameter " #a " is variable %s<%s> with NULL var_decl_node", \
- __func__, \
- a->name, \
- cbl_field_type_str(a->type) ); \
- gcc_unreachable(); \
- } \
- }while(0);
-
-#define CHECK_LABEL(a) \
- do{ \
- if(!a) \
- { \
- yywarn("%s(): parameter " #a " is NULL", __func__); \
- gcc_unreachable(); \
- } \
+#define CHECK_FIELD(a) \
+ do { \
+ if(!a) \
+ { \
+ yywarn("%s: parameter %<" #a "%> is NULL", __func__); \
+ gcc_unreachable(); \
+ } \
+ if( !a->var_decl_node && a->type != FldConditional && a->type != FldLiteralA) \
+ { \
+ yywarn("%s: parameter %<" #a "%> is variable " \
+ "%s<%s> with NULL %<var_decl_node%>", \
+ __func__, \
+ a->name, \
+ cbl_field_type_str(a->type) ); \
+ gcc_unreachable(); \
+ } \
+ } while(0);
+
+#define CHECK_LABEL(a) \
+ do{ \
+ if(!a) \
+ { \
+ yywarn("%s: parameter %<" #a "%> is NULL", __func__); \
+ gcc_unreachable(); \
+ } \
}while(0);
#ifdef INCORPORATE_ANALYZER
diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc
index d75ca29..089c9c1 100644
--- a/gcc/cobol/symbols.cc
+++ b/gcc/cobol/symbols.cc
@@ -2836,7 +2836,7 @@ seek_parent( const symbol_elem_t *e, size_t level ) {
struct symbol_elem_t *
symbol_field_same_as( cbl_field_t *tgt, const cbl_field_t *src ) {
if( target_in_src(tgt, src) ) {
- ERROR_FIELD(tgt, "%s %s may not reference itself as part of %s %s",
+ ERROR_FIELD(tgt, "%s %s may not reference itself as part of %s %s",
tgt->level_str(), tgt->name, src->level_str(), src->name);
return NULL;
}
@@ -3088,7 +3088,7 @@ cbl_alphabet_t::assign( const YYLTYPE& loc, unsigned char ch, unsigned char high
return true;
}
auto taken = alphabet[ch];
- error_msg(loc, "ALPHABET %s, character '%c' (X'%x') "
+ error_msg(loc, "ALPHABET %s, character %<%c%> (X%'%x%') "
"in position %d already defined at position %d",
name,
ISPRINT(ch)? ch : '?', ch,
@@ -3493,7 +3493,7 @@ cbl_field_t::internalize() {
static const size_t noconv = size_t(-1);
if (cd == (iconv_t)-1) {
- yywarn("failed iconv_open tocode = '%s' fromcode = %s", tocode, fromcode);
+ yywarn("failed %<iconv_open%> tocode = %<%s%> fromcode = %s", tocode, fromcode);
}
bool using_assumed = fromcode == os_locale.assumed;
diff --git a/gcc/cobol/symbols.h b/gcc/cobol/symbols.h
index 84a984e..c09fbcc 100644
--- a/gcc/cobol/symbols.h
+++ b/gcc/cobol/symbols.h
@@ -131,13 +131,13 @@ is_numeric( cbl_field_type_t type ) {
case FldIndex:
return true;
}
- yywarn( "%s:%d: invalid symbol_type_t %d", __func__, __LINE__, type );
+ cbl_internal_error( "%s:%d: invalid %<symbol_type_t%> %d", __func__, __LINE__, type );
return false;
}
struct os_locale_t {
char assumed[16];
- char *codeset;
+ const char *codeset;
};
const char * cbl_field_attr_str( cbl_field_attr_t attr );
@@ -1216,6 +1216,8 @@ class temporaries_t {
literal_an() : is_quoted(false), value("???") {}
literal_an( const char value[], bool is_quoted )
: is_quoted(is_quoted), value(value) {}
+ literal_an( const literal_an& that )
+ : is_quoted(that.is_quoted), value(that.value) {}
literal_an& operator=( const literal_an& that ) {
is_quoted = that.is_quoted;
value = that.value;
@@ -1495,7 +1497,7 @@ struct cbl_alphabet_t {
}
void dump() const {
- yywarn("'%s': %s, '%c' to '%c' (low 0x%02x, high 0x%02x)",
+ yywarn("%qs: %s, %<%c%> to %<%c%> (low 0x%x, high 0x%x)",
name, encoding_str(encoding),
low_index, last_index, low_index, high_index);
if( encoding == custom_encoding_e ) {
diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc
index b6c9280..d8423e0 100644
--- a/gcc/cobol/util.cc
+++ b/gcc/cobol/util.cc
@@ -130,7 +130,7 @@ symbol_type_str( enum symbol_type_t type )
case SymDataSection:
return "SymDataSection";
}
- dbgmsg("%s:%d: invalid symbol_type_t %d", __func__, __LINE__, type);
+ cbl_internal_error("%s:%d: invalid %<symbol_type_t%> %d", __func__, __LINE__, type);
return "???";
}
@@ -179,7 +179,7 @@ cbl_field_type_str( enum cbl_field_type_t type )
case FldBlob:
return "FldBlob";
}
- dbgmsg("%s:%d: invalid symbol_type_t %d", __func__, __LINE__, type);
+ cbl_internal_error("%s:%d: invalid %<symbol_type_t%> %d", __func__, __LINE__, type);
return "???";
}
@@ -479,7 +479,7 @@ is_elementary( enum cbl_field_type_t type )
case FldFloat:
return true; // takes up space
}
- dbgmsg("%s:%d: invalid symbol_type_t %d", __func__, __LINE__, type);
+ cbl_internal_error("%s:%d: invalid %<symbol_type_t%> %d", __func__, __LINE__, type);
return false;
}
@@ -902,8 +902,8 @@ cbl_field_t::report_invalid_initial_value(const YYLTYPE& loc) const {
return TOUPPER(ch) == 'E';
} );
if( !has_exponent && data.precision() < pend - p ) {
- error_msg(loc, "%s cannot represent VALUE '%s' exactly (max .%zu)",
- name, data.initial, pend - p);
+ error_msg(loc, "%s cannot represent VALUE %qs exactly (max %c%zu)",
+ name, data.initial, '.', pend - p);
}
}
}
@@ -1805,7 +1805,7 @@ class unique_stack : public std::stack<input_file_t>
(fmt_size_t)(c.size() - --n), v.lineno, no_wd(wd, v.name) );
}
} else {
- dbgmsg("unable to get current working directory: %m");
+ dbgmsg("unable to get current working directory: %s", xstrerror(errno));
}
free(wd);
}
@@ -1953,6 +1953,8 @@ verify_format( const char gmsgid[] ) {
static const diagnostic_option_id option_zero;
size_t parse_error_inc();
+void ydferror( const char gmsgid[], ... ) ATTRIBUTE_GCOBOL_DIAG(1, 2);
+
void
ydferror( const char gmsgid[], ... ) {
verify_format(gmsgid);
@@ -2029,6 +2031,9 @@ void error_msg( const YYLTYPE& loc, const char gmsgid[], ... ) {
ERROR_MSG_BODY
}
+void error_msg( const YDFLTYPE& loc, const char gmsgid[], ... )
+ ATTRIBUTE_GCOBOL_DIAG(2, 3);
+
void error_msg( const YDFLTYPE& loc, const char gmsgid[], ... ) {
ERROR_MSG_BODY
}
@@ -2119,7 +2124,7 @@ cobol_fileline_set( const char line[] ) {
dbgmsg( "%s:%d: could not compile regex: %s", __func__, __LINE__, regexmsg );
return line;
}
- error_msg(yylloc, "invalid #line directive: %s", line );
+ error_msg(yylloc, "invalid %<#line%> directive: %s", line );
return line;
}
@@ -2129,7 +2134,7 @@ cobol_fileline_set( const char line[] ) {
int fileline;
if( 1 != sscanf(line_str, "%d", &fileline) )
- yywarn("could not parse line number %s from #line directive", line_str);
+ yywarn("could not parse line number %s from %<#line%> directive", line_str);
input_file_t input_file( filename, ino_t(0), fileline ); // constructor sets inode
@@ -2216,19 +2221,9 @@ cobol_set_debugging( bool flex, bool yacc, bool parser )
yy_flex_debug = flex? 1 : 0;
ydfdebug = yydebug = yacc? 1 : 0;
f_trace_debug = parser? 1 : 0;
-
- char *ind = getenv("INDICATOR_COLUMN");
- if( ind ) {
- int col;
- if( 1 != sscanf(ind, "%d", &col) ) {
- yywarn("ignored non-integer value for INDICATOR_COLUMN=%s", ind);
- }
- cobol_set_indicator_column(col);
- }
}
-os_locale_t os_locale = { "UTF-8", xstrdup("C.UTF-8") };
-
+os_locale_t os_locale = { "UTF-8", "C.UTF-8" };
void
cobol_parse_files (int nfile, const char **files)
@@ -2239,7 +2234,7 @@ cobol_parse_files (int nfile, const char **files)
} else {
char *codeset = nl_langinfo(CODESET);
if( ! codeset ) {
- yywarn("nl_langinfo failed after setlocale succeeded");
+ yywarn("%<nl_langinfo%> failed after %<setlocale()%> succeeded");
} else {
os_locale.codeset = codeset;
}
@@ -2351,7 +2346,7 @@ dbgmsg(const char *msg, ...) {
void
dialect_error( const YYLTYPE& loc, const char term[], const char dialect[] ) {
- error_msg(loc, "%s is not ISO syntax, requires -dialect %s",
+ error_msg(loc, "%s is not ISO syntax, requires %<-dialect %s%>",
term, dialect);
}
diff --git a/gcc/cobol/util.h b/gcc/cobol/util.h
index 54d3930..9388b50 100644
--- a/gcc/cobol/util.h
+++ b/gcc/cobol/util.h
@@ -31,11 +31,13 @@
#ifndef _UTIL_H_
#define _UTIL_H_
-void cbl_message(int fd, const char *format_string, ...);
-void cbl_internal_error(const char *format_string, ...);
+void cbl_message(int fd, const char *format_string, ...)
+ ATTRIBUTE_PRINTF_2;
+void cbl_internal_error(const char *format_string, ...)
+ ATTRIBUTE_GCOBOL_DIAG(1, 2);
-void cbl_err(const char *format_string, ...);
-void cbl_errx(const char *format_string, ...);
+void cbl_err(const char *format_string, ...) ATTRIBUTE_GCOBOL_DIAG(1, 2);
+void cbl_errx(const char *format_string, ...) ATTRIBUTE_GCOBOL_DIAG(1, 2);
bool fisdigit(int c);
bool fisspace(int c);