Changeset 2810700 for src


Ignore:
Timestamp:
Feb 22, 2024, 1:43:00 PM (4 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
2beaf9b
Parents:
7bb516f
Message:

The two argument form of the conditional operator now only has two arguments all the way to the resolver.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r7bb516f r2810700  
    10411041                // FIX ME: computes $1 twice
    10421042        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    1043                 { $$ = new ExpressionNode( build_cond( yylloc, $1, $1->clone(), $4 ) ); }
     1043                { $$ = new ExpressionNode( build_cond( yylloc, $1, nullptr, $4 ) ); }
    10441044        ;
    10451045
  • src/ResolvExpr/CandidateFinder.cpp

    r7bb516f r2810700  
    15121512        void Finder::postvisit( const ast::ConditionalExpr * conditionalExpr ) {
    15131513                // candidates for condition
     1514                ast::ptr<ast::Expr> arg1 = notZeroExpr( conditionalExpr->arg1 );
    15141515                CandidateFinder finder1( context, tenv );
    1515                 ast::ptr<ast::Expr> arg1 = notZeroExpr( conditionalExpr->arg1 );
    15161516                finder1.find( arg1, ResolveMode::withAdjustment() );
    15171517                if ( finder1.candidates.empty() ) return;
    15181518
    15191519                // candidates for true result
     1520                ast::Expr const * arg2 = conditionalExpr->arg2;
     1521                arg2 = arg2 ? arg2 : conditionalExpr->arg1.get();
    15201522                CandidateFinder finder2( context, tenv );
    15211523                finder2.allowVoid = true;
    1522                 finder2.find( conditionalExpr->arg2, ResolveMode::withAdjustment() );
     1524                finder2.find( arg2, ResolveMode::withAdjustment() );
    15231525                if ( finder2.candidates.empty() ) return;
    15241526
Note: See TracChangeset for help on using the changeset viewer.