https://gcc.gnu.org/g:1c6f621e134874ddf75d1a910fd4b198d2e6f7e5

commit r17-2667-g1c6f621e134874ddf75d1a910fd4b198d2e6f7e5
Author: James K. Lowden <[email protected]>
Date:   Thu Jul 23 10:00:28 2026 -0400

    cobol: Recognize TYPE clause as implicit USAGE for validation.
    
    gcc/cobol/ChangeLog:
    
            * parse.y: Add value_clause_e to bitmask for test.
            * symbols.cc (symbols_update): Improve diagnostic message.

Diff:
---
 gcc/cobol/parse.y    |  4 +++-
 gcc/cobol/symbols.cc | 13 +++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index 06a3cfb5fd58..e03403f64a98 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -4536,8 +4536,10 @@ data_descr1:    level_name
                   // Any field may become a group, so may have VALUE with no 
PICTURE
                   const auto stooges3 = (picture_clause_e |
                                          value_clause_e |
+                                         type_clause_e |
                                          usage_clause_e);
-                  if( ($data_clauses & stooges3) == value_clause_e ) { // only
+                  auto clauses($data_clauses);
+                  if( (clauses & stooges3) == value_clause_e ) { // only
                     $field->type = FldInvalid;
                     auto fig = cbl_figconst_of($field->data.original());
                     if( null_value_e != fig ) {
diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc
index e9a0e2bb0a01..1416c189bf45 100644
--- a/gcc/cobol/symbols.cc
+++ b/gcc/cobol/symbols.cc
@@ -1923,10 +1923,10 @@ symbols_update( size_t first, bool parsed_ok ) {
        * and its size is calculated above.  If that doesn't happen, it gets
        * flagged here.
        */
-      if( yydebug || parse_error_count() == 0 ) {
+      if( parse_error_count() == 0 ) {
         if( field->type == FldInvalid ) {
-          ERROR_FIELD(field, "line %d: %s %s requires PICTURE",
-                  field->line, field->level_str(), field->name);
+          ERROR_FIELD(field, "%s %s requires PICTURE",
+                  field->level_str(), field->name);
 
         } else {
           cbl_internal_error("%s: data item %s #" HOST_SIZE_T_PRINT_UNSIGNED
@@ -1985,9 +1985,10 @@ symbols_update( size_t first, bool parsed_ok ) {
     }
 
     if( field->type == FldInvalid ) {
-      dbgmsg("%s:%d: %s", __func__, __LINE__, field_str(field));
-      ERROR_FIELD(field, "line %d: %s %s requires PICTURE",
-              field->line, field->level_str(), field->name);
+      dbgmsg("%s:%d: %-20s %s", __func__, __LINE__,
+             cbl_field_type_str(field->type), field_str(field));
+      ERROR_FIELD(field, "%s %s requires PICTURE",
+              field->level_str(), field->name);
       continue;
     }
     if( is_numeric(field) && ! field->has_attr(constant_e) ) {

Reply via email to