diff --git a/gcc/cobol/cbldiag.h b/gcc/cobol/cbldiag.h index 47892177c6cc8eda8d3ce57e809315295f70eae7..ded7ab72b04c86a88e296708390b09fd7d203b86 100644 --- a/gcc/cobol/cbldiag.h +++ b/gcc/cobol/cbldiag.h @@ -68,7 +68,18 @@ void dbgmsg( const char fmt[], ... ); template <typename LOC> void gcc_location_set( const LOC& loc ); +#if defined(USE_LOCATION_DUMP) && !defined(LOCATION_DUMP_DEFINED) template <typename LOC> -void location_dump( const char func[], int line, - const char tag[], const LOC& loc); +static void +location_dump( const char func[], int line, const char tag[], const LOC& loc) { + extern int yy_flex_debug; + extern int yydebug; + if( yy_flex_debug || yydebug ) + 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); +} +#define LOCATION_DUMP_DEFINED +#endif + diff --git a/gcc/cobol/cdf.y b/gcc/cobol/cdf.y index 799b7ecda80e1077424e15d5150a152d4153e278..9ea858164192e45c031f925dbfd65871bd95cb23 100644 --- a/gcc/cobol/cdf.y +++ b/gcc/cobol/cdf.y @@ -29,6 +29,8 @@ */ %{ +#define USE_LOCATION_DUMP + #include "cobol-system.h" #include "symbols.h" #include "copybook.h" @@ -69,7 +71,6 @@ static int ydflex(void); const YYLTYPE& cobol_location(); static YYLTYPE location_set( const YYLTYPE& loc ); - #define YYLLOC_DEFAULT(Current, Rhs, N) \ do { \ if (N) \ diff --git a/gcc/cobol/lexio.cc b/gcc/cobol/lexio.cc index 9098a414b546bd9e9da3d3646026f968a395bd5e..1c4bc9d102a11e413d3ffbc2b6b2b5cef8700783 100644 --- a/gcc/cobol/lexio.cc +++ b/gcc/cobol/lexio.cc @@ -28,6 +28,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define USE_LOCATION_DUMP + #include <ext/stdio_filebuf.h> #include "cobol-system.h" #include "cbldiag.h" diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h index 78d5af0541857449be841c52222df6accf971f7d..9dc6fb01cf556dcb79c6537d781907b0b0eed85c 100644 --- a/gcc/cobol/parse_ante.h +++ b/gcc/cobol/parse_ante.h @@ -28,6 +28,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define USE_LOCATION_DUMP + #include "genapi.h" #include "io.h" #include "ec.h" diff --git a/gcc/cobol/scan_ante.h b/gcc/cobol/scan_ante.h index ab62fc6057bed5ffd8104529d541da567ebb72f8..ac89185ccfc9996117ce50c557fc3da510a7e419 100644 --- a/gcc/cobol/scan_ante.h +++ b/gcc/cobol/scan_ante.h @@ -28,6 +28,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define USE_LOCATION_DUMP + #include "parse.h" #include "cdf.h" #include "symbols.h" diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc index 2de8dc0d3be47be090d52838245342f700065da7..a740cef46838673109b50825838d0863c936525d 100644 --- a/gcc/cobol/util.cc +++ b/gcc/cobol/util.cc @@ -34,6 +34,8 @@ * header files. */ +#define USE_LOCATION_DUMP + #include "cobol-system.h" #include <langinfo.h> @@ -2169,8 +2171,6 @@ namespace none { error_msg(YDFLTYPE(), "also fake"); gcc_location_set(YYLTYPE()); gcc_location_set(YDFLTYPE()); - location_dump("also", 0, "also", YYLTYPE()); - location_dump("fake", 0, "fake", YDFLTYPE()); } }; @@ -2190,15 +2190,6 @@ error_msg( const LOC& loc, const char gmsgid[], ... ) { global_dc->end_group(); } -template <typename LOC> -void -location_dump( const char func[], int line, const char tag[], const LOC& loc) { - if( yy_flex_debug || yydebug ) - 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); -} - void cdf_location_set(YYLTYPE loc) { extern YDFLTYPE ydflloc;