From 518e56a5f58dcd72e1eff3706b4755b2bb2311a8 Mon Sep 17 00:00:00 2001
From: "James K. Lowden" <jklowden@symas.com>
Date: Thu, 25 Apr 2024 19:22:17 -0400
Subject: [PATCH] small fix

---
 gcc/cobol/scan.l     | 3 +--
 gcc/cobol/symbols.cc | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l
index 758754a1c3e0..70fe98dd35c6 100644
--- a/gcc/cobol/scan.l
+++ b/gcc/cobol/scan.l
@@ -1776,9 +1776,8 @@ COPY		{
                   ydflval.string = yylval.string = strdup(yytext);
 
                   int token = keyword_tok(null_trim(yylval.string), true);
-		  auto elem = symbol_field(PROGRAM, 0, yylval.string);
 
-                  if( token && ! elem ) { // not a data item name
+                  if( token && ! symbol_field(PROGRAM, 0, yylval.string) ) { 
                     // If token is an intrinsic, and not in Repository, pretend
                     // it's a name and let the parser sort it out.
                     auto name = intrinsic_function_name(token);
diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc
index b09d38892f59..00f271fd4829 100644
--- a/gcc/cobol/symbols.cc
+++ b/gcc/cobol/symbols.cc
@@ -1940,7 +1940,7 @@ symbol_field_parent_set( struct cbl_field_t *field )
       auto redefined = symbol_redefines(prior);
       if( redefined ) prior = redefined;
       field->parent = prior->parent;
-      return prior;
+      return cbl_field_of(symbol_at(field->parent));
     }
     
     if( prior->level < field->level ) {
-- 
GitLab