Changeset b0dfbc4


Ignore:
Timestamp:
Sep 1, 2017, 7:03:25 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
1395748, dbc733e
Parents:
5809461
git-author:
Rob Schluntz <rschlunt@…> (09/01/17 19:00:17)
git-committer:
Rob Schluntz <rschlunt@…> (09/01/17 19:03:25)
Message:

Clean up BranchStmt? code

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Statement.cc

    r5809461 rb0dfbc4  
    8989
    9090BranchStmt::BranchStmt( std::list<Label> labels, Label target, Type type ) throw ( SemanticError ) :
    91         Statement( labels ), originalTarget( target ), target( target ), computedTarget( NULL ), type( type ) {
     91        Statement( labels ), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) {
    9292        //actually this is a syntactic error signaled by the parser
    93         if ( type == BranchStmt::Goto && target.empty() )
     93        if ( type == BranchStmt::Goto && target.empty() ) {
    9494                throw SemanticError("goto without target");
     95        }
    9596}
    9697
    9798BranchStmt::BranchStmt( std::list<Label> labels, Expression *computedTarget, Type type ) throw ( SemanticError ) :
    9899        Statement( labels ), computedTarget( computedTarget ), type( type ) {
    99         if ( type != BranchStmt::Goto || computedTarget == 0 )
     100        if ( type != BranchStmt::Goto || computedTarget == nullptr ) {
    100101                throw SemanticError("Computed target not valid in branch statement");
     102        }
    101103}
    102104
    103105void BranchStmt::print( std::ostream &os, int indent ) const {
    104106        os << string( indent, ' ' ) << "Branch (" << brType[type] << ")" << endl ;
     107        if ( target != "" ) os << string( indent+2, ' ' ) << "with target: " << target << endl;
     108        if ( originalTarget != "" ) os << string( indent+2, ' ' ) << "with original target: " << originalTarget << endl;
     109        if ( computedTarget != nullptr ) os << string( indent+2, ' ' ) << "with computed target: " << computedTarget << endl;
    105110}
    106111
  • src/tests/.expect/dtor-early-exit-ERR1.txt

    r5809461 rb0dfbc4  
    11dtor-early-exit.c:142:1 error: jump to label 'L1' crosses initialization of y Branch (Goto)
     2  with target: L1
     3  with original target: L1
    24
  • src/tests/.expect/dtor-early-exit-ERR2.txt

    r5809461 rb0dfbc4  
    11dtor-early-exit.c:142:1 error: jump to label 'L2' crosses initialization of y Branch (Goto)
     2  with target: L2
     3  with original target: L2
    24
Note: See TracChangeset for help on using the changeset viewer.