[gcc r17-2837] cobol: Restore SECTION number warnings.
"James K. Lowden via Gcc-cvs" <[email protected]> Thu, 30 Jul 2026 22:49:11 +0000 (GMT)
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:cec7574ff3f1559066b209c1973a383efc341fb0 commit r17-2837-gcec7574ff3f1559066b209c1973a383efc341fb0 Author: James K. Lowden <[email protected]> Date: Thu Jul 30 22:26:37 2026 +0000 cobol: Restore SECTION number warnings. Lexer recognizes SECTION explicitly and handles it correctly. gcc/cobol/ChangeLog: * parse.y (dialect_ok): Enable messages without a quoted tagline. * scan.l: Add SECTION pattern so it is not handled by general NAME pattern. Diff: --- gcc/cobol/parse.y | 46 +++++++++++++++++++++------------------------- gcc/cobol/scan.l | 1 + 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y index eef000a7ee60..ae0371ae886a 100644 --- a/gcc/cobol/parse.y +++ b/gcc/cobol/parse.y @@ -8032,31 +8032,27 @@ section_name: NAME section_kw '.' ; section_kw: SECTION -/* Dubner commented out this code on 2026-06-28 as part of getting the - compiler working on the IBM S390. It was failing in an off-by-one way; - the $1 parameter, on the S390, wasn't the section number, but rather the - section name. */ -// { -// if( $1 && dialect_ok(@1, IbmSectionSegmentW, "SECTION segment") ) { -// cbl_message(@1, IbmSectionSegmentW, -// "SECTION segment %qs was ignored", $1); -// if( *$1 == '-' ) { -// cbl_message(@1, IbmSectionNegE, -// "SECTION segment %qs is negative", $1); -// } else { -// int sectno; -// sscanf($1, "%d", §no); -// if( ! (0 <= sectno && sectno <= 99) ) { -// cbl_message(@1, IbmSectionRangeE, -// "SECTION segment %qs must be 0-99", $1); -// } -// } -// } -// } -// | SECTION error -// { -// error_msg(@1, "unknown section qualifier"); -// } + { + if( $1 && dialect_ok(@1, IbmSectionSegmentW, "SECTION segment") ) { + cbl_message(@1, IbmSectionSegmentW, + "SECTION segment %qs was ignored", $1); + if( *$1 == '-' ) { + cbl_message(@1, IbmSectionNegE, + "SECTION segment %qs is negative", $1); + } else { + int sectno; + sscanf($1, "%d", §no); + if( ! (0 <= sectno && sectno <= 99) ) { + cbl_message(@1, IbmSectionRangeE, + "SECTION segment %qs must be 0-99", $1); + } + } + } + } + | SECTION error + { + error_msg(@1, "unknown section qualifier"); + } ; stop: STOP RUN exit_with diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l index 278cad8b1545..85603117e92d 100644 --- a/gcc/cobol/scan.l +++ b/gcc/cobol/scan.l @@ -1987,6 +1987,7 @@ USE({SPC}FOR)? { return USE; } FUNCTION { yy_push_state(function); return FUNCTION; } + SECTION{OSPC}/{DOTSEP} { yylval.string = NULL; return SECTION; } SECTION{OSPC}[.]+{SPC}/USE[[:space:]] { yylval.string = NULL; return SECTION; } [.]+({SPC}(EJECT|SKIP[123]))*{SPC}EXIT{OSPC}/{DOTSEP} {