Ignore:
Timestamp:
Jun 2, 2015, 3:31:41 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, string, with_gc
Children:
27de955
Parents:
4eb1db6
Message:

fix label forward referencesC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/LabelFixer.cc

    r4eb1db6 r954463b8  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 29 15:57:12 2015
    13 // Update Count     : 82
     12// Last Modified On : Tue Jun 02 15:30:32 2015
     13// Update Count     : 93
    1414//
    1515
     
    7676                assert( llabel.size() > 0 );
    7777
     78                Entry * e = new Entry( definition );
     79
    7880                for ( std::list< Label >::iterator i = llabel.begin(); i != llabel.end(); i++ ) {
    79                         if ( labelTable.find( *i ) == labelTable.end() ) {
     81                        if ( labelTable.find( *i ) == labelTable.end() ) {
     82                                // all labels on this statement need to use the same entry, so this should only be created once
    8083                                // undefined and unused until now, add an entry
    81                                 labelTable[ *i ] =  new Entry( definition );
    82                         } else if ( labelTable[ *i ]->defined() ) {\
     84                                labelTable[ *i ] =  e;
     85                        } else if ( labelTable[ *i ]->defined() ) {
    8386                                // defined twice, error
    8487                                throw SemanticError( "Duplicate definition of label: " + *i );
    8588                        }       else {
    86                                 // used previously, but undefined until now -> set its definition to this location
    87                                 labelTable[ *i ]->set_definition( definition );
     89                                // used previously, but undefined until now -> link with this entry
     90                                Entry * oldEntry = labelTable[ *i ];
     91                                e->add_uses( oldEntry->get_uses() );
     92                                labelTable[ *i ] = e;
    8893                        } // if
    8994                } // for
Note: See TracChangeset for help on using the changeset viewer.