Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    r59c8dff r4a89b52  
    5252#include "Common/Stats/Counter.h"
    5353
    54 #include "AST/Inspect.hpp"             // for getFunctionName
    55 
    5654#define PRINT( text ) if ( resolvep ) { text }
    5755
     
    658656                void postvisit( const ast::OffsetofExpr * offsetofExpr );
    659657                void postvisit( const ast::OffsetPackExpr * offsetPackExpr );
    660                 void postvisit( const ast::EnumPosExpr * enumPosExpr );
    661658                void postvisit( const ast::LogicalExpr * logicalExpr );
    662659                void postvisit( const ast::ConditionalExpr * conditionalExpr );
     
    14741471        void Finder::postvisit( const ast::OffsetPackExpr * offsetPackExpr ) {
    14751472                addCandidate( offsetPackExpr, tenv );
    1476         }
    1477 
    1478         void Finder::postvisit( const ast::EnumPosExpr * enumPosExpr ) {
    1479                 CandidateFinder finder( context, tenv );
    1480                 finder.find( enumPosExpr->expr );
    1481                 CandidateList winners = findMinCost( finder.candidates );
    1482                 if ( winners.size() != 1 ) SemanticError( enumPosExpr->expr.get(), "Ambiguous expression in position. ");
    1483                 CandidateRef & choice = winners.front();
    1484                 auto refExpr = referenceToRvalueConversion( choice->expr, choice->cost );
    1485                 auto refResult = (refExpr->result).as<ast::EnumInstType>();
    1486                 if ( !refResult ) {
    1487                         SemanticError( refExpr, "Position for Non enum type is not supported" );
    1488                 }
    1489                 // determineEnumPosConstant( enumPosExpr, refResult );
    1490 
    1491                 const ast::NameExpr * const nameExpr = enumPosExpr->expr.strict_as<ast::NameExpr>();
    1492                 const ast::EnumDecl * base = refResult->base;
    1493                 if ( !base ) {
    1494                         SemanticError( enumPosExpr, "Cannot be reference to a defined enumeration type" );
    1495                 }
    1496                 auto it = std::find_if( std::begin( base->members ), std::end( base->members ),
    1497                         [nameExpr]( ast::ptr<ast::Decl> decl ) { return decl->name == nameExpr->name; } );
    1498                 unsigned position = it - base->members.begin();
    1499                 addCandidate( ast::ConstantExpr::from_int( enumPosExpr->location, position ), tenv );
    15001473        }
    15011474
Note: See TracChangeset for help on using the changeset viewer.