From e709e1dcc64da52c6ecbcf4b83ad59a7924e66be Mon Sep 17 00:00:00 2001
From: "James K. Lowden" <jklowden@symas.com>
Date: Thu, 19 Dec 2024 10:23:36 -0500
Subject: [PATCH] allow "section" to be part of a name

---
 gcc/cobol/scan.l     | 5 ++---
 gcc/cobol/symbols.cc | 6 ++----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l
index f742a5a756aa..5b0e553ec26a 100644
--- a/gcc/cobol/scan.l
+++ b/gcc/cobol/scan.l
@@ -598,8 +598,7 @@ PLUS		{ return PLUS; }
 PICTURE         { return PICTURE; }
 PH		{ return PH; }
 PF		{ return PF; }
-PERFORM		         { yylval.boolean = false; return PERFORM; }
-
+PERFORM		  { yylval.boolean = false; return PERFORM; }
 PERFORM{SPC}CYCLE { yylval.boolean = true;  return PERFORM; }
 
 PAGE-COUNTER	{ return PAGE_COUNTER; }
@@ -1500,7 +1499,7 @@ USE({SPC}FOR)?		{ return USE; }
   STACK                 { return STACK; }
   TOP-LEVEL             { return TOP_LEVEL; }
 
-  {NAME}/{SPC}SECTION {   yylval.string = strdup(yytext);
+  {NAME}/{SPC}SECTION\b { yylval.string = strdup(yytext);
                           return NAME; }
 
   (IS{SPC})?POSITIVE/[[:space:]]  { yylval.number =  IS; return POSITIVE; }
diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc
index b111c60710d5..572b831bd99e 100644
--- a/gcc/cobol/symbols.cc
+++ b/gcc/cobol/symbols.cc
@@ -3995,10 +3995,8 @@ symbol_label_add( size_t program, cbl_label_t *input )
 
 /*
  * Under ISO (and not IBM) Declaratives are followed by a Section name.  When
- * the first statement is parsed, the last symbol in the table is the first
- * symbol, if any, in the Procedure Division.  If it's a user-defined Section
- * name, it doesn't matter if there are Declaratives.  Else check to see if
- * there *are* Declaratives to notify the user of the missing Section name.
+ * the first statement is parsed, verify, if Declaratives were used, that it
+ * was preceeded by a Section name.
  */
 bool
 symbol_label_section_exists( size_t program ) {
-- 
GitLab