Ignore:
Timestamp:
Apr 12, 2024, 7:49:21 AM (2 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
3e1cd17, 90320ac
Parents:
feb999f (diff), ab780e6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    rfeb999f rb78c54f  
    340340        }
    341341
     342        ast::ptr< ast::Expr > findCondExpression(
     343                const ast::Expr * untyped, const ResolveContext & context
     344        ) {
     345                if ( nullptr == untyped ) return untyped;
     346                ast::ptr<ast::Expr> condExpr = createCondExpr( untyped );
     347                return findIntegralExpression( condExpr, context );
     348        }
     349
    342350        /// check if a type is a character type
    343351        bool isCharType( const ast::Type * t ) {
     
    356364                return it != end;
    357365        }
    358 }
     366} // anonymous namespace
    359367
    360368class Resolver final
     
    729737const ast::IfStmt * Resolver::previsit( const ast::IfStmt * ifStmt ) {
    730738        return ast::mutate_field(
    731                 ifStmt, &ast::IfStmt::cond, findIntegralExpression( ifStmt->cond, context ) );
     739                ifStmt, &ast::IfStmt::cond, findCondExpression( ifStmt->cond, context ) );
    732740}
    733741
    734742const ast::WhileDoStmt * Resolver::previsit( const ast::WhileDoStmt * whileDoStmt ) {
    735743        return ast::mutate_field(
    736                 whileDoStmt, &ast::WhileDoStmt::cond, findIntegralExpression( whileDoStmt->cond, context ) );
     744                whileDoStmt, &ast::WhileDoStmt::cond, findCondExpression( whileDoStmt->cond, context ) );
    737745}
    738746
     
    740748        if ( forStmt->cond ) {
    741749                forStmt = ast::mutate_field(
    742                         forStmt, &ast::ForStmt::cond, findIntegralExpression( forStmt->cond, context ) );
     750                        forStmt, &ast::ForStmt::cond, findCondExpression( forStmt->cond, context ) );
    743751        }
    744752
     
    10751083
    10761084                // Resolve the conditions as if it were an IfStmt, statements normally
    1077                 clause2->when_cond = findSingleExpression( clause.when_cond, context );
     1085                clause2->when_cond = findCondExpression( clause.when_cond, context );
    10781086                clause2->stmt = clause.stmt->accept( *visitor );
    10791087
     
    10891097                        new ast::BasicType{ ast::BasicType::LongLongUnsignedInt };
    10901098                auto timeout_time = findSingleExpression( stmt->timeout_time, target, context );
    1091                 auto timeout_cond = findSingleExpression( stmt->timeout_cond, context );
     1099                auto timeout_cond = findCondExpression( stmt->timeout_cond, context );
    10921100                auto timeout_stmt = stmt->timeout_stmt->accept( *visitor );
    10931101
     
    11021110        if ( stmt->else_stmt ) {
    11031111                // resolve the condition like IfStmt, stmts normally
    1104                 auto else_cond = findSingleExpression( stmt->else_cond, context );
     1112                auto else_cond = findCondExpression( stmt->else_cond, context );
    11051113                auto else_stmt = stmt->else_stmt->accept( *visitor );
    11061114
Note: See TracChangeset for help on using the changeset viewer.