diff options
Diffstat (limited to 'gcc/cobol/cbldiag.h')
-rw-r--r-- | gcc/cobol/cbldiag.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/gcc/cobol/cbldiag.h b/gcc/cobol/cbldiag.h index 49dc44b..39f1369 100644 --- a/gcc/cobol/cbldiag.h +++ b/gcc/cobol/cbldiag.h @@ -33,7 +33,7 @@ #else #define _CBLDIAG_H -#if 0 +#if GCOBOL_GETENV #define gcobol_getenv(x) getenv(x) #else #define gcobol_getenv(x) ((char *)nullptr) @@ -78,10 +78,15 @@ struct YDFLTYPE #endif +// Diagnostic format specifiers are documented in gcc/pretty-print.cc // an error at a location, called from the parser for semantic errors void error_msg( const YYLTYPE& loc, const char gmsgid[], ... ) ATTRIBUTE_GCOBOL_DIAG(2, 3); +bool +warn_msg( const YYLTYPE& loc, const char gmsgid[], ... ) + ATTRIBUTE_GCOBOL_DIAG(2, 3); + // an error that uses token_location, not yylloc void error_msg_direct( const char gmsgid[], ... ) ATTRIBUTE_GCOBOL_DIAG(1, 2); @@ -116,11 +121,14 @@ template <typename LOC> static void location_dump( const char func[], int line, const char tag[], const LOC& loc) { extern int yy_flex_debug; // cppcheck-suppress shadowVariable - if( yy_flex_debug && gcobol_getenv("update_location") ) { - fprintf(stderr, "%s:%d: %s location (%d,%d) to (%d,%d)\n", - func, line, tag, - loc.first_line, loc.first_column, loc.last_line, loc.last_column); - gcc_location_dump(); + if( yy_flex_debug ) { + const char *detail = gcobol_getenv("update_location"); + if( detail ) { + fprintf(stderr, "%s:%d: %s location (%d,%d) to (%d,%d)\n", + func, line, tag, + loc.first_line, loc.first_column, loc.last_line, loc.last_column); + if( *detail == '2' ) gcc_location_dump(); + } } } #endif // defined(yy_flex_debug) |