Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r6ef2d81 r3a5131ed  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  9 15:54:59 2017
    13 // Update Count     : 742
     12// Last Modified On : Thu Feb 16 13:06:50 2017
     13// Update Count     : 753
    1414//
    1515
     
    913913        SemanticError errors;
    914914        std::back_insert_iterator< std::list< Declaration * > > out( outputList );
    915         const DeclarationNode * cur = firstNode;
    916 
    917         while ( cur ) {
     915
     916        for ( const DeclarationNode * cur = firstNode; cur; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ) ) {
    918917                try {
    919918                        if ( DeclarationNode * extr = cur->extractAggregate() ) {
     
    921920                                Declaration * decl = extr->build();
    922921                                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;
    930931                                * out++ = decl;
    931932                        } // if
    932933                } catch( SemanticError &e ) {
     934                        e.set_location( cur->location );
    933935                        errors.append( e );
    934936                } // try
    935                 cur = dynamic_cast< DeclarationNode * >( cur->get_next() );
    936937        } // while
    937938
     
    944945        SemanticError errors;
    945946        std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList );
    946         const DeclarationNode * cur = firstNode;
    947         while ( cur ) {
     947       
     948        for ( const DeclarationNode * cur = firstNode; cur; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ) ) {
    948949                try {
    949950                        Declaration * decl = cur->build();
    950951                        if ( decl ) {
    951952                                if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
     953                                        dwt->location = cur->location;
    952954                                        * out++ = dwt;
    953955                                } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {
    954956                                        StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() );
    955                                         * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr );
     957                                        auto obj = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr );
     958                                        obj->location = cur->location;
     959                                        * out++ = obj;
    956960                                        delete agg;
    957961                                } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
    958962                                        UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );
    959                                         * out++ = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr );
     963                                        auto obj = new ObjectDecl( "", DeclarationNode::NoStorageClass, linkage, nullptr, inst, nullptr );
     964                                        obj->location = cur->location;
     965                                        * out++ = obj;
    960966                                } // if
    961967                        } // if
    962968                } catch( SemanticError &e ) {
     969                        e.set_location( cur->location );
    963970                        errors.append( e );
    964971                } // try
    965                 cur = dynamic_cast< DeclarationNode * >( cur->get_next() );
    966         } // while
     972        } // for
     973
    967974        if ( ! errors.isEmpty() ) {
    968975                throw errors;
     
    979986                        * out++ = cur->buildType();
    980987                } catch( SemanticError &e ) {
     988                        e.set_location( cur->location );
    981989                        errors.append( e );
    982990                } // try
Note: See TracChangeset for help on using the changeset viewer.