From f453b9ed408fc0b7f53891ec3d06aee0c6997b82 Mon Sep 17 00:00:00 2001
From: "James K. Lowden" <jklowden@symas.com>
Date: Mon, 29 Apr 2024 15:05:57 -0400
Subject: [PATCH] allow line directive before paragraph

---
 gcc/cobol/parse.y | 6 +++---
 gcc/cobol/scan.l  | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index 424e9e35e13e..a213e5c916de 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -9966,9 +9966,9 @@ class tokenset_t {
     }, * const eonames = cdf_names + COUNT_OF(cdf_names);
     
     if( std::any_of(cdf_names, eonames,
-		    [candidate=name](const cbl_name_t name) {
-		      return 0 == strcasecmp(name, candidate)
-			&& strlen(name) == strlen(candidate);
+		    [candidate=name](const cbl_name_t cdf_name) {
+		      return 0 == strcasecmp(cdf_name, candidate)
+			&& strlen(cdf_name) == strlen(candidate);
 		    } ) ) {
       return false; // CDF names are never ordinary tokens
     }
diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l
index ed05268c77b3..4cee696d4eff 100644
--- a/gcc/cobol/scan.l
+++ b/gcc/cobol/scan.l
@@ -1897,7 +1897,8 @@ COPY		{
 	   		if( yy_flex_debug ) warnx("resuming at line %4d of %s",
 						  yylineno, name? name : "<none>"); }
 
-  {LINE_DIRECTIVE} {	cobol_fileline_set(yytext); }
+  {LINE_DIRECTIVE} {	penultimate_once(final_token);
+			cobol_fileline_set(yytext); }
 }
 
 
-- 
GitLab