[gcc r17-2834] cobol: Relax parsing restrictions for void sentences and MF $END-IF.

"James K. Lowden via Gcc-cvs" <[email protected]> Thu, 30 Jul 2026 21:10:52 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:7a320f883fe3cbaa0ce0003d6a4eb3fc043d2e49

commit r17-2834-g7a320f883fe3cbaa0ce0003d6a4eb3fc043d2e49
Author: James K. Lowden <[email protected]>
Date:   Thu Jul 30 15:16:39 2026 -0400

    cobol: Relax parsing restrictions for void sentences and MF $END-IF.
    
    Accept multiple consecutive periods as empty statements.  Accept
    undocumented $END-IF under -dialect mf without comment.
    
    gcc/cobol/ChangeLog:
    
            PR cobol/126495
            PR cobol/126496
            * gcobol.1: Update manual to reflect new syntax.
            * parse.y: Allow void sentence and increment s/r expected count to 7.
            * scan.l: Lex $END-IF, optionally, as $END.

Diff:
---
 gcc/cobol/gcobol.1 | 3 +++
 gcc/cobol/parse.y  | 7 ++++---
 gcc/cobol/scan.l   | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gcc/cobol/gcobol.1 b/gcc/cobol/gcobol.1
index aff6c1c7431e..36addddeb89f 100644
--- a/gcc/cobol/gcobol.1
+++ b/gcc/cobol/gcobol.1
@@ -491,6 +491,9 @@ to indicate GnuCOBOL syntax, generally compatible with MicroFocus.
 to indicate MicroFocus syntax:
 .Bl -bullet -compact
 .It
+CDF
+.Sy $IF , $ELSE , $END , Sy $END-IF , Li and Sy $SET
+.It
 .Sy BINARY-LONG-LONG
 .It
 .Sy CALL ... GIVING
diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index d6cd656085bb..13a94ffc59ef 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -730,7 +730,7 @@ class locale_tgt_t {
     // https://savannah.gnu.org/forum/forum.php?forum_id=9735
 %token  YYEOF 0 "end of file"
 
-%type   <number>        sentence statements statement
+%type   <number>        statements statement
 %type   <number>        star_cbl_opt close_how
 
 %type   <number>        test_before usage_clause1 might_be alphanational
@@ -1566,7 +1566,7 @@ class locale_tgt_t {
 %locations
 %token-table
 %define parse.error verbose // custom
-%expect 6
+%expect 7
 %require "3.5.1"  //    3.8.2 also works, but not 3.8.0
 %%
 
@@ -5691,7 +5691,8 @@ paragraph_name: NAME
         |       NUMSTR { $$ = $1.string; }
 		;
 
-sentence:       statements  '.'
+sentence:       '.'
+        |       statements  '.'
         |       statements  YYEOF
                 {
                   if( ! goodnight_gracie() ) {
diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l
index 67bdefa91dc8..278cad8b1545 100644
--- a/gcc/cobol/scan.l
+++ b/gcc/cobol/scan.l
@@ -2439,7 +2439,7 @@ BASIS		{ yy_push_state(basis); return BASIS; }
 				  yy_push_state(cdf_state); return CDF_IF; }
   ^[ ]*[$]{OBLANK}ELSE	 	{ dialect_ok(yylloc, MfCdfDollar, yytext); 
 				  return CDF_ELSE; }
-  ^[ ]*[$]{OBLANK}END	 	{ dialect_ok(yylloc, MfCdfDollar, yytext); 
+  ^[ ]*[$]{OBLANK}END(-IF)? 	{ dialect_ok(yylloc, MfCdfDollar, yytext); 
 				  return CDF_END_IF; }
 
   ^[ ]*[$]{OBLANK}SET({SPC}CONSTANT)? {