Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    rdcd73d1 r1ba88a0  
    2323                };
    2424
    25                 class InitDepthChecker : public Visitor {
    26                 public:
    27                         bool depthOkay = true;
    28                         Type * type;
    29                         int curDepth = 0, maxDepth = 0;
    30                         InitDepthChecker( Type * type ) : type( type ) {
    31                                 Type * t = type;
    32                                 while ( ArrayType * at = dynamic_cast< ArrayType * >( t ) ) {
    33                                         maxDepth++;
    34                                         t = at->get_base();
    35                                 }
    36                                 maxDepth++;
    37                         }
    38                         virtual void visit( ListInit * listInit ) {
    39                                 curDepth++;
    40                                 if ( curDepth > maxDepth ) depthOkay = false;
    41                                 Visitor::visit( listInit );
    42                                 curDepth--;
    43                         }
    44                 };
    45 
    4625                class InitFlattener : public Visitor {
    4726                        public:
     
    7453                maybeAccept( init, finder );
    7554                return finder.hasDesignations;
    76         }
    77 
    78         bool checkInitDepth( ObjectDecl * objDecl ) {
    79                 InitDepthChecker checker( objDecl->get_type() );
    80                 maybeAccept( objDecl->get_init(), checker );
    81                 return checker.depthOkay;
    8255        }
    8356
Note: See TracChangeset for help on using the changeset viewer.