Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r3a5131ed r6ef2d81  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 13:06:50 2017
    13 // Update Count     : 753
     12// Last Modified On : Thu Feb  9 15:54:59 2017
     13// Update Count     : 742
    1414//
    1515
     
    913913        SemanticError errors;
    914914        std::back_insert_iterator< std::list< Declaration * > > out( outputList );
    915 
    916         for ( const DeclarationNode * cur = firstNode; cur; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ) ) {
     915        const DeclarationNode * cur = firstNode;
     916
     917        while ( cur ) {
    917918                try {
    918919                        if ( DeclarationNode * extr = cur->extractAggregate() ) {
     
    920921                                Declaration * decl = extr->build();
    921922                                if ( decl ) {
    922                                         decl->location = cur->location;
    923923                                        * out++ = decl;
    924924                                } // if
     
    928928                        Declaration * decl = cur->build();
    929929                        if ( decl ) {
    930                                 decl->location = cur->location;
    931930                                * out++ = decl;
    932931                        } // if
    933932                } catch( SemanticError &e ) {
    934                         e.set_location( cur->location );
    935933                        errors.append( e );
    936934                } // try
     935                cur = dynamic_cast< DeclarationNode * >( cur->get_next() );
    937936        } // while
    938937
     
    945944        SemanticError errors;
    946945        std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList );
    947        
    948         for ( const DeclarationNode * cur = firstNode; cur; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ) ) {
     946        const DeclarationNode * cur = firstNode;
     947        while ( cur ) {
    949948                try {
    950949                        Declaration * decl = cur->build();
    951950                        if ( decl ) {
    952951                                if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
    953                                         dwt->location = cur->location;
    954952                                        * out++ = dwt;
    955953                                } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {
    956954                                        StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() );
    957                                         auto obj = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr );
    958                                         obj->location = cur->location;
    959                                         * out++ = obj;
     955                                        * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr );
    960956                                        delete agg;
    961957                                } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
    962958                                        UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );
    963                                         auto obj = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr );
    964                                         obj->location = cur->location;
    965                                         * out++ = obj;
     959                                        * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr );
    966960                                } // if
    967961                        } // if
    968962                } catch( SemanticError &e ) {
    969                         e.set_location( cur->location );
    970963                        errors.append( e );
    971964                } // try
    972         } // for
    973 
     965                cur = dynamic_cast< DeclarationNode * >( cur->get_next() );
     966        } // while
    974967        if ( ! errors.isEmpty() ) {
    975968                throw errors;
     
    986979                        * out++ = cur->buildType();
    987980                } catch( SemanticError &e ) {
    988                         e.set_location( cur->location );
    989981                        errors.append( e );
    990982                } // try
Note: See TracChangeset for help on using the changeset viewer.