diff --git a/gcc/cobol/cdf_text.h b/gcc/cobol/cdf_text.h index aae8c138f7fe81fb133ab2b624338da401c75cf9..d93b82df32c63e5808d2bee0b3fa24edea2797b6 100644 --- a/gcc/cobol/cdf_text.h +++ b/gcc/cobol/cdf_text.h @@ -256,6 +256,8 @@ cdftext::map_file( int fd ) { return mfile; } +bool lexio_dialect_mf(); + filespan_t cdftext::free_form_reference_format( int input ) { filespan_t source_buffer = map_file(input); @@ -358,12 +360,15 @@ cdftext::free_form_reference_format( int input ) { erase_source(indcol, mfile.eol); } continue; + case '$': + if( lexio_dialect_mf() ) { + break; + } + __attribute__ ((fallthrough)); default: // ignore other characters in indicator area if( isspace(indcol[0])) break; - if( yy_flex_debug ) { - warnx("--stray indicator 0x%0x \"%s\", line %zu", - indcol[0], indcol, mfile.lineno); - } + warnx("warning: stray indicator 0x%0x \"%s\" %zu", + indcol[0], indcol, mfile.lineno); *indcol = SPACE; break; } diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l index 8670e6ca907d388656626cc3344d00482fde31b4..acd7c9f959243dede8690ce430a1aa35fcf6bdc0 100644 --- a/gcc/cobol/scan.l +++ b/gcc/cobol/scan.l @@ -1845,6 +1845,13 @@ COPY { ^[ ]*>>{OSPC}ELSE { return CDF_ELSE; } ^[ ]*>>{OSPC}END-IF { return CDF_END_IF; } + ^[ ]*[$]{OSPC}IF { if( ! dialect_mf() ) dialect_error( yytext, "mf"); + return CDF_IF; } + ^[ ]*[$]{OSPC}ELSE { if( ! dialect_mf() ) dialect_error( yytext, "mf"); + return CDF_ELSE; } + ^[ ]*[$]{OSPC}END { if( ! dialect_mf() ) dialect_error( yytext, "mf"); + return CDF_END_IF; } + ^[ ]*>>{OSPC}EVALUATE { return CDF_EVALUATE; } ^[ ]*>>{OSPC}WHEN { return CDF_WHEN; } ^[ ]*>>{OSPC}END-EVALUATE { return CDF_END_EVALUATE; } diff --git a/gcc/cobol/scan_ante.h b/gcc/cobol/scan_ante.h index c2b734902c4261ddc24b4648c8f6bd3cc69a07b6..a2422211453335c919332fbdde3711b7eaf20526 100644 --- a/gcc/cobol/scan_ante.h +++ b/gcc/cobol/scan_ante.h @@ -105,6 +105,12 @@ lexer_echo() { return echo_on; } +static void +dialect_error( const char term[], const char dialect[] ) { + yyerrorv("error: %s is not ISO syntax, requires -dialect %s", + term, dialect); +} + // IBM says a picture can be up to 50 bytes, not 1000 words. // ISO says a picture can be up to 63 bytes. We allow for a NUL terminator. static char orig_picture[PICTURE_MAX]; diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc index 4d62198cc9318af566965634ad33ce8e525571c4..886e502696f5a67d899fd03129313a6b714fb49d 100644 --- a/gcc/cobol/symbols.cc +++ b/gcc/cobol/symbols.cc @@ -49,6 +49,9 @@ #pragma GCC diagnostic ignored "-Wunused-result" +bool +lexio_dialect_mf() { return dialect_mf(); } + class symbol_pair_t { const symbol_elem_t *first, *last; diff --git a/gcc/cobol/symbols.h b/gcc/cobol/symbols.h index 6c1fcc7c790783b69d2935c7a9c54558de498fef..d20f18598486f3377f288d2f211af4bc269d54b6 100644 --- a/gcc/cobol/symbols.h +++ b/gcc/cobol/symbols.h @@ -394,6 +394,7 @@ const char * time_is_now(void); void yyerrorv( const char fmt[], ... ); void yyerrorvl( int line, const char fmt[], ... ); +void yywarnv( const char fmt[], ... ); struct cbl_upsi_mask_t { bool on_off;