This is another step towards removing the COUNT_OF macro.

gcc/cobol/ChangeLog:

        * parse.y: Use range-based 'for' to iterate over arrays.
        * symbols.cc (symbol_table_init): Likewise.
---
 gcc/cobol/parse.y    | 9 ++++-----
 gcc/cobol/symbols.cc | 7 +++----
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index 5ccb4e35881..e82ad73ede2 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -7395,10 +7395,9 @@ perform_ec:      EXCEPTION filenames {
                  for( auto p = $except_files->elems.begin();
                       p != $except_files->elems.end(); ) {
                    auto dcl = new cbl_declarative_t;
-                   for( auto file = dcl->files;
-                        file < dcl->files + COUNT_OF(dcl->files); file++ ) {
+                   for( auto& file : dcl->files ) {
                      if( p != $except_files->elems.end() ) break;
-                     *file = *p++;
+                     file = *p++;
                    }
                    dcls->elems.push_back(dcl);
                  }
@@ -11865,8 +11864,8 @@ current_data_section_set(const YYLTYPE& loc,  
data_section_t data_section ) {
 void apply_declaratives() {
   // look for declaratives for this procedure, and all procedures
   bool tf[2] = { false, true };
-  for( bool *yn = tf; yn < tf + COUNT_OF(tf); yn++ ) {
-    auto declaratives = current.debugging_declaratives(*yn);
+  for( bool yn : tf ) {
+    auto declaratives = current.debugging_declaratives(yn);
     for( auto p  = declaratives.begin() ;
          p != declaratives.end(); p++ ) {
       // TODO: delarative for PARA OF SECTION
diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc
index 2b352ea99c9..67a9f039bc0 100644
--- a/gcc/cobol/symbols.cc
+++ b/gcc/cobol/symbols.cc
@@ -2322,11 +2322,10 @@ symbol_table_init(void) {
     { 0, FldConditional, FldInvalid, constant_e , 0, 0, 0, nonarray, 0,
       "_VERY_FALSE", 0, {}, {1,1,0,0, ""}, NULL },
   };
-  for( struct cbl_field_t *f = constants;
-       f < constants + COUNT_OF(constants); f++ ) {
-    f->our_index = table.nelem;
+  for( struct cbl_field_t &f : constants ) {
+    f.our_index = table.nelem;
     struct symbol_elem_t sym(SymField, 0);
-    sym.elem.field = *f;
+    sym.elem.field = f;
     table.elems[table.nelem++] = sym;
   }
 
-- 
2.48.1

Reply via email to