Changes in src/InitTweak/InitTweak.cc [dcd73d1:1ba88a0]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/InitTweak.cc
rdcd73d1 r1ba88a0 23 23 }; 24 24 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 46 25 class InitFlattener : public Visitor { 47 26 public: … … 74 53 maybeAccept( init, finder ); 75 54 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;82 55 } 83 56
Note:
See TracChangeset
for help on using the changeset viewer.