From 99369b2ab8195669d11f59e24775377669b32c31 Mon Sep 17 00:00:00 2001
From: "James K. Lowden" <jklowden@symas.com>
Date: Fri, 1 Mar 2024 16:36:46 -0500
Subject: [PATCH] add file+line to internal scanner error

---
 gcc/cobol/scan.l      |  2 +-
 gcc/cobol/scan_ante.h | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l
index b3e55f9b0649..12846708b745 100644
--- a/gcc/cobol/scan.l
+++ b/gcc/cobol/scan.l
@@ -1839,7 +1839,7 @@ COPY		{
 			penultimate_once(final_token);
 			auto name = cobol_filename_restore();
 	   		if( yy_flex_debug ) warnx("restoring line %4d of %s",
-						  yylineno, name? name : "<none>g"); }
+						  yylineno, name? name : "<none>"); }
 }
 
 
diff --git a/gcc/cobol/scan_ante.h b/gcc/cobol/scan_ante.h
index d71b229657f3..3fa4086c718c 100644
--- a/gcc/cobol/scan_ante.h
+++ b/gcc/cobol/scan_ante.h
@@ -43,6 +43,19 @@
 #include "symbols.h"
 #include "copybook.h"
 
+/*
+ * Flex override
+ */
+static void /* yynoreturn */ yy_fatal_error ( const char* msg  );
+
+static void inline
+die_fatal_error( const char msg[] ) {
+  yyerrorv("scan.o: %s",  msg); 
+  yy_fatal_error(msg);
+}
+
+#define YY_FATAL_ERROR(msg) die_fatal_error((msg))
+
 /*
  * External functions
  */
-- 
GitLab