Changeset 9506c70


Ignore:
Timestamp:
Feb 24, 2025, 4:58:06 PM (7 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
b8b64c34
Parents:
4be0117
Message:

Stricter BranchStmt code generation that should prevent some of the warning cases removed in the concurrency test update. This also caught a bad case in the control flow handling code.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cpp

    r4be0117 r9506c70  
    11051105                assertf( !options.genC, "fallthrough should not reach code generation." );
    11061106                output << "fallthrough";
     1107                if ( ast::BranchStmt::FallThroughDefault == stmt->kind ) {
     1108                        assertf( stmt->target.empty(), "fallthough default should not have a target." );
     1109                        output << " default";
     1110                }
    11071111                break;
    11081112        default:
    11091113                assertf( false, "Bad BranchStmt value." );
    11101114        }
    1111         // Print branch target for labelled break/continue/fallthrough in debug mode.
    1112         if ( !options.genC && stmt->kind != ast::BranchStmt::Goto ) {
    1113                 if ( !stmt->target.empty() ) {
    1114                         output << " " << stmt->target;
    1115                 } else if ( stmt->kind == ast::BranchStmt::FallThrough ) {
    1116                         output << " default";
    1117                 }
     1115        // Print branch target for labelled break/continue/fallthrough.
     1116        if ( ast::BranchStmt::Goto != stmt->kind && !stmt->target.empty() ) {
     1117                assertf( !options.genC, "labelled branch should not reach code generation. %s", stmt->target.name.c_str() );
     1118                output << " " << stmt->target;
    11181119        }
    11191120        output << ";";
  • src/ControlStruct/MultiLevelExit.cpp

    r4be0117 r9506c70  
    499499                }
    500500
     501                // The end of the last case is always immediately before the first
     502                // statement after the switch, so we can jump here as a break.
    501503                auto mutCase = mutStmt->cases.back().get_and_mutate();
    502 
    503                 Label label( mutCase->location, "breakLabel" );
    504                 auto branch = new BranchStmt( mutCase->location, BranchStmt::Break, label );
    505                 branch->labels.push_back( entry.useBreakExit() );
     504                auto branch = labelledNullStmt( mutCase->location, entry.useBreakExit() );
    506505                mutCase->stmts.push_back( branch );
    507506
Note: See TracChangeset for help on using the changeset viewer.