Changes in / [7c782af:62cd621]


Ignore:
Location:
src
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r7c782af r62cd621  
    764764
    765765        void CodeGenerator::postvisit( StmtExpr * stmtExpr ) {
    766                 std::list< Statement * > & stmts = stmtExpr->statements->kids;
     766                std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids();
    767767                output << "({" << endl;
    768768                ++indent;
     
    775775                                // cannot cast to void, otherwise the expression statement has no value
    776776                                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) {
    777                                         exprStmt->expr->accept( *visitor );
     777                                        exprStmt->get_expr()->accept( *visitor );
    778778                                        output << ";" << endl;
    779779                                        ++i;
     
    795795                assertf( ! genC, "Unique expressions should not reach code generation." );
    796796                expr->callExpr->accept( *visitor );
    797         }
    798 
    799         void CodeGenerator::postvisit( DeletedExpr * expr ) {
    800                 assertf( ! genC, "Deleted expressions should not reach code generation." );
    801                 expr->expr->accept( *visitor );
    802797        }
    803798
  • src/CodeGen/CodeGenerator.h

    r7c782af r62cd621  
    8888                void postvisit( StmtExpr * );
    8989                void postvisit( ConstructorExpr * );
    90                 void postvisit( DeletedExpr * );
    9190
    9291                //*** Statements
  • src/Common/PassVisitor.h

    r7c782af r62cd621  
    121121        virtual void visit( UntypedInitExpr *  initExpr ) override final;
    122122        virtual void visit( InitExpr *  initExpr ) override final;
    123         virtual void visit( DeletedExpr *  delExpr ) override final;
    124123
    125124        virtual void visit( VoidType * basicType ) override final;
     
    216215        virtual Expression * mutate( UntypedInitExpr *  initExpr ) override final;
    217216        virtual Expression * mutate( InitExpr *  initExpr ) override final;
    218         virtual Expression * mutate( DeletedExpr *  delExpr ) override final;
    219217
    220218        virtual Type * mutate( VoidType * basicType ) override final;
     
    305303        void indexerAddUnionFwd ( UnionDecl                 * node  ) { indexer_impl_addUnionFwd ( pass, 0, node ); }
    306304        void indexerAddTrait    ( TraitDecl                 * node  ) { indexer_impl_addTrait    ( pass, 0, node ); }
    307         void indexerAddWith     ( std::list< Expression * > & exprs, BaseSyntaxNode * withStmt ) { indexer_impl_addWith     ( pass, 0, exprs, withStmt ); }
     305        void indexerAddWith     ( std::list< Expression * > & exprs ) { indexer_impl_addWith     ( pass, 0, exprs ); }
    308306
    309307
  • src/Common/PassVisitor.impl.h

    r7c782af r62cd621  
    393393                // shadow with exprs and not the other way around.
    394394                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    395                 indexerAddWith( node->withExprs, node );
     395                indexerAddWith( node->withExprs );
    396396                {
    397397                        auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     
    423423                // shadow with exprs and not the other way around.
    424424                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    425                 indexerAddWith( node->withExprs, node );
     425                indexerAddWith( node->withExprs );
    426426                {
    427427                        auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     
    10641064                // catch statements introduce a level of scope (for the caught exception)
    10651065                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1066                 indexerAddWith( node->exprs, node );
     1066                indexerAddWith( node->exprs );
    10671067                maybeAccept_impl( node->stmt, *this );
    10681068        }
     
    10771077                // catch statements introduce a level of scope (for the caught exception)
    10781078                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1079                 indexerAddWith( node->exprs, node );
     1079                indexerAddWith( node->exprs );
    10801080                maybeMutate_impl( node->stmt, *this );
    10811081        }
     
    19711971}
    19721972
    1973 //--------------------------------------------------------------------------
    1974 // DeletedExpr
    1975 template< typename pass_type >
    1976 void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
    1977         VISIT_START( node );
    1978 
    1979         indexerScopedAccept( node->result, *this );
    1980         maybeAccept_impl( node->expr, *this );
    1981         // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
    1982 
    1983         VISIT_END( node );
    1984 }
    1985 
    1986 template< typename pass_type >
    1987 Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
    1988         MUTATE_START( node );
    1989 
    1990         indexerScopedMutate( node->env, *this );
    1991         indexerScopedMutate( node->result, *this );
    1992         maybeMutate_impl( node->expr, *this );
    1993 
    1994         MUTATE_END( Expression, node );
    1995 }
    1996 
    1997 
    19981973template< typename pass_type >
    19991974void PassVisitor< pass_type >::visit( VoidType * node ) {
  • src/Common/PassVisitor.proto.h

    r7c782af r62cd621  
    193193
    194194
    195 #define INDEXER_FUNC1( func, type )                                                                                             \
     195#define INDEXER_FUNC( func, type )                                                                                             \
    196196template<typename pass_type>                                                                                                   \
    197197static inline auto indexer_impl_##func ( pass_type & pass, int, type arg ) -> decltype( pass.indexer.func( arg ), void() ) {   \
     
    202202static inline void indexer_impl_##func ( pass_type &, long, type ) { }                                                          \
    203203
    204 #define INDEXER_FUNC2( func, type1, type2 )                                                                                             \
    205 template<typename pass_type>                                                                                                   \
    206 static inline auto indexer_impl_##func ( pass_type & pass, int, type1 arg1, type2 arg2 ) -> decltype( pass.indexer.func( arg1, arg2 ), void() ) {   \
    207         pass.indexer.func( arg1, arg2 );                                                                                                \
    208 }                                                                                                                              \
    209                                                                                                                                \
    210 template<typename pass_type>                                                                                                   \
    211 static inline void indexer_impl_##func ( pass_type &, long, type1, type2 ) { }
    212 
    213 
    214 INDEXER_FUNC1( addId     , DeclarationWithType *       );
    215 INDEXER_FUNC1( addType   , NamedTypeDecl *             );
    216 INDEXER_FUNC1( addStruct , StructDecl *                );
    217 INDEXER_FUNC1( addEnum   , EnumDecl *                  );
    218 INDEXER_FUNC1( addUnion  , UnionDecl *                 );
    219 INDEXER_FUNC1( addTrait  , TraitDecl *                 );
    220 INDEXER_FUNC2( addWith   , std::list< Expression * > &, BaseSyntaxNode * );
     204INDEXER_FUNC( addId     , DeclarationWithType *       );
     205INDEXER_FUNC( addType   , NamedTypeDecl *             );
     206INDEXER_FUNC( addStruct , StructDecl *                );
     207INDEXER_FUNC( addEnum   , EnumDecl *                  );
     208INDEXER_FUNC( addUnion  , UnionDecl *                 );
     209INDEXER_FUNC( addTrait  , TraitDecl *                 );
     210INDEXER_FUNC( addWith   , std::list< Expression * > & );
    221211
    222212
  • src/Common/utility.h

    r7c782af r62cd621  
    9898}
    9999
    100 template< typename SrcContainer, typename DestContainer, typename Predicate >
    101 void cloneAll_if( const SrcContainer &src, DestContainer &dest, Predicate pred ) {
    102         std::back_insert_iterator< DestContainer > out( dest );
    103         for ( auto x : src ) {
    104                 if ( pred(x) ) {
    105                         *out++ = x->clone();
    106                 }
    107         } // while
    108 }
    109 
    110100template< typename Container >
    111101void assertAll( const Container &container ) {
  • src/ResolvExpr/Alternative.h

    r7c782af r62cd621  
    5757        /// Moves all elements from src to the beginning of dst
    5858        void spliceBegin( AltList& dst, AltList& src );
    59 
    60         static inline std::ostream & operator<<(std::ostream & os, const ResolvExpr::Alternative & alt) {
    61                 alt.print( os );
    62                 return os;
    63         }
    6459} // namespace ResolvExpr
    6560
  • src/ResolvExpr/AlternativeFinder.cc

    r7c782af r62cd621  
    9595                void postvisit( StmtExpr * stmtExpr );
    9696                void postvisit( UntypedInitExpr * initExpr );
    97                 void postvisit( InitExpr * initExpr );
    98                 void postvisit( DeletedExpr * delExpr );
    9997
    10098                /// Adds alternatives for anonymous members
     
    122120                Type *& targetType;
    123121        };
     122
     123        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ) {
     124                CastExpr *castToVoid = new CastExpr( expr );
     125
     126                AlternativeFinder finder( indexer, env );
     127                finder.findWithAdjustment( castToVoid );
     128
     129                // it's a property of the language that a cast expression has either 1 or 0 interpretations; if it has 0
     130                // interpretations, an exception has already been thrown.
     131                assert( finder.get_alternatives().size() == 1 );
     132                CastExpr *newExpr = dynamic_cast< CastExpr* >( finder.get_alternatives().front().expr );
     133                assert( newExpr );
     134                env = finder.get_alternatives().front().env;
     135                return newExpr->get_arg()->clone();
     136        }
    124137
    125138        Cost sumCost( const AltList &in ) {
     
    13671380        void AlternativeFinder::Finder::postvisit( NameExpr *nameExpr ) {
    13681381                std::list< SymTab::Indexer::IdData > declList;
    1369                 indexer.lookupId( nameExpr->name, declList );
    1370                 PRINT( std::cerr << "nameExpr is " << nameExpr->name << std::endl; )
     1382                indexer.lookupId( nameExpr->get_name(), declList );
     1383                PRINT( std::cerr << "nameExpr is " << nameExpr->get_name() << std::endl; )
    13711384                for ( auto & data : declList ) {
    13721385                        Expression * newExpr = data.combine();
     
    13891402                // not sufficient to clone here, because variable's type may have changed
    13901403                // since the VariableExpr was originally created.
    1391                 alternatives.push_back( Alternative( new VariableExpr( variableExpr->var ), env, Cost::zero ) );
     1404                alternatives.push_back( Alternative( new VariableExpr( variableExpr->get_var() ), env, Cost::zero ) );
    13921405        }
    13931406
     
    14561469                // xxx - resolveTypeof?
    14571470                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( offsetofExpr->get_type() ) ) {
    1458                         addOffsetof( structInst, offsetofExpr->member );
     1471                        addOffsetof( structInst, offsetofExpr->get_member() );
    14591472                } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( offsetofExpr->get_type() ) ) {
    1460                         addOffsetof( unionInst, offsetofExpr->member );
     1473                        addOffsetof( unionInst, offsetofExpr->get_member() );
    14611474                }
    14621475        }
     
    15351548                secondFinder.findWithAdjustment( logicalExpr->get_arg2() );
    15361549                if ( secondFinder.alternatives.empty() ) return;
    1537                 for ( const Alternative & first : firstFinder.alternatives ) {
    1538                         for ( const Alternative & second : secondFinder.alternatives ) {
     1550                for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) {
     1551                        for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) {
    15391552                                TypeEnvironment compositeEnv;
    1540                                 compositeEnv.simpleCombine( first.env );
    1541                                 compositeEnv.simpleCombine( second.env );
    1542 
    1543                                 LogicalExpr *newExpr = new LogicalExpr( first.expr->clone(), second.expr->clone(), logicalExpr->get_isAnd() );
    1544                                 alternatives.push_back( Alternative( newExpr, compositeEnv, first.cost + second.cost ) );
     1553                                compositeEnv.simpleCombine( first->env );
     1554                                compositeEnv.simpleCombine( second->env );
     1555
     1556                                LogicalExpr *newExpr = new LogicalExpr( first->expr->clone(), second->expr->clone(), logicalExpr->get_isAnd() );
     1557                                alternatives.push_back( Alternative( newExpr, compositeEnv, first->cost + second->cost ) );
    15451558                        }
    15461559                }
     
    15921605                AlternativeFinder secondFinder( indexer, newEnv );
    15931606                secondFinder.findWithAdjustment( commaExpr->get_arg2() );
    1594                 for ( const Alternative & alt : secondFinder.alternatives ) {
    1595                         alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt.expr->clone() ), alt.env, alt.cost ) );
     1607                for ( AltList::const_iterator alt = secondFinder.alternatives.begin(); alt != secondFinder.alternatives.end(); ++alt ) {
     1608                        alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt->expr->clone() ), alt->env, alt->cost ) );
    15961609                } // for
    15971610                delete newFirstArg;
     
    16011614                // resolve low and high, accept alternatives whose low and high types unify
    16021615                AlternativeFinder firstFinder( indexer, env );
    1603                 firstFinder.findWithAdjustment( rangeExpr->low );
     1616                firstFinder.findWithAdjustment( rangeExpr->get_low() );
    16041617                if ( firstFinder.alternatives.empty() ) return;
    16051618                AlternativeFinder secondFinder( indexer, env );
    1606                 secondFinder.findWithAdjustment( rangeExpr->high );
     1619                secondFinder.findWithAdjustment( rangeExpr->get_high() );
    16071620                if ( secondFinder.alternatives.empty() ) return;
    1608                 for ( const Alternative & first : firstFinder.alternatives ) {
    1609                         for ( const Alternative & second : secondFinder.alternatives ) {
     1621                for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) {
     1622                        for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) {
    16101623                                TypeEnvironment compositeEnv;
    1611                                 compositeEnv.simpleCombine( first.env );
    1612                                 compositeEnv.simpleCombine( second.env );
     1624                                compositeEnv.simpleCombine( first->env );
     1625                                compositeEnv.simpleCombine( second->env );
    16131626                                OpenVarSet openVars;
    16141627                                AssertionSet needAssertions, haveAssertions;
    1615                                 Alternative newAlt( 0, compositeEnv, first.cost + second.cost );
     1628                                Alternative newAlt( 0, compositeEnv, first->cost + second->cost );
    16161629                                Type* commonType = nullptr;
    1617                                 if ( unify( first.expr->result, second.expr->result, newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
    1618                                         RangeExpr * newExpr = new RangeExpr( first.expr->clone(), second.expr->clone() );
    1619                                         newExpr->result = commonType ? commonType : first.expr->result->clone();
     1630                                if ( unify( first->expr->get_result(), second->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
     1631                                        RangeExpr *newExpr = new RangeExpr( first->expr->clone(), second->expr->clone() );
     1632                                        newExpr->set_result( commonType ? commonType : first->expr->get_result()->clone() );
    16201633                                        newAlt.expr = newExpr;
    16211634                                        inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) );
     
    17381751                findMinCost( minArgCost.begin(), minArgCost.end(), std::back_inserter( alternatives ) );
    17391752        }
    1740 
    1741         void AlternativeFinder::Finder::postvisit( InitExpr * ) {
    1742                 assertf( false, "AlternativeFinder should never see a resolved InitExpr." );
    1743         }
    1744 
    1745         void AlternativeFinder::Finder::postvisit( DeletedExpr * ) {
    1746                 assertf( false, "AlternativeFinder should never see a DeletedExpr." );
    1747         }
    17481753} // namespace ResolvExpr
    17491754
  • src/ResolvExpr/Resolver.cc

    r7c782af r62cd621  
    105105        }
    106106
    107         namespace {
    108                 struct DeleteFinder : public WithShortCircuiting        {
    109                         DeletedExpr * delExpr = nullptr;
    110                         void previsit( DeletedExpr * expr ) {
    111                                 if ( delExpr ) visit_children = false;
    112                                 else delExpr = expr;
    113                         }
    114 
    115                         void previsit( Expression * ) {
    116                                 if ( delExpr ) visit_children = false;
    117                         }
    118                 };
    119         }
    120 
    121         DeletedExpr * findDeletedExpr( Expression * expr ) {
    122                 PassVisitor<DeleteFinder> finder;
    123                 expr->accept( finder );
    124                 return finder.pass.delExpr;
     107        // used in resolveTypeof
     108        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ) {
     109                TypeEnvironment env;
     110                return resolveInVoidContext( expr, indexer, env );
    125111        }
    126112
     
    144130        } // namespace
    145131
    146         namespace {
    147                 void findUnfinishedKindExpression(Expression * untyped, Alternative & alt, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, bool adjust = false, bool prune = true, bool failFast = true) {
    148                         assertf( untyped, "expected a non-null expression." );
    149                         TypeEnvironment env;
    150                         AlternativeFinder finder( indexer, env );
    151                         finder.find( untyped, adjust, prune, failFast );
    152 
    153                         #if 0
    154                         if ( finder.get_alternatives().size() != 1 ) {
    155                                 std::cerr << "untyped expr is ";
    156                                 untyped->print( std::cerr );
    157                                 std::cerr << std::endl << "alternatives are:";
    158                                 for ( const Alternative & alt : finder.get_alternatives() ) {
    159                                         alt.print( std::cerr );
    160                                 } // for
    161                         } // if
    162                         #endif
    163 
    164                         AltList candidates;
    165                         for ( Alternative & alt : finder.get_alternatives() ) {
    166                                 if ( pred( alt ) ) {
    167                                         candidates.push_back( std::move( alt ) );
    168                                 }
    169                         }
    170 
    171                         // xxx - if > 1 alternative with same cost, ignore deleted and pick from remaining
    172                         // choose the lowest cost expression among the candidates
    173                         AltList winners;
    174                         findMinCost( candidates.begin(), candidates.end(), back_inserter( winners ) );
    175                         if ( winners.size() == 0 ) {
    176                                 throw SemanticError( untyped, toString( "No reasonable alternatives for ", kindStr, (kindStr != "" ? " " : ""), "expression: ") );
    177                         } else if ( winners.size() != 1 ) {
    178                                 std::ostringstream stream;
    179                                 stream << "Cannot choose between " << winners.size() << " alternatives for " << kindStr << (kindStr != "" ? " " : "") << "expression\n";
    180                                 untyped->print( stream );
    181                                 stream << "Alternatives are:\n";
    182                                 printAlts( winners, stream, 1 );
    183                                 throw SemanticError( untyped->location, stream.str() );
    184                         }
    185 
    186                         // there is one unambiguous interpretation - move the expression into the with statement
    187                         Alternative & choice = winners.front();
    188                         if ( findDeletedExpr( choice.expr ) ) {
    189                                 throw SemanticError( choice.expr, "Unique best alternative includes deleted identifier in " );
    190                         }
    191                         alt = std::move( choice );
    192                 }
    193 
    194                 /// resolve `untyped` to the expression whose alternative satisfies `pred` with the lowest cost; kindStr is used for providing better error messages
    195                 void findKindExpression(Expression *& untyped, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, bool adjust = false, bool prune = true, bool failFast = true) {
    196                         if ( ! untyped ) return;
    197                         Alternative choice;
    198                         findUnfinishedKindExpression( untyped, choice, indexer, kindStr, pred, adjust, prune, failFast );
    199                         finishExpr( choice.expr, choice.env, untyped->env );
    200                         delete untyped;
    201                         untyped = choice.expr;
    202                         choice.expr = nullptr;
    203                 }
    204 
    205                 bool standardAlternativeFilter( const Alternative & ) {
    206                         // currently don't need to filter, under normal circumstances.
    207                         // in the future, this may be useful for removing deleted expressions
    208                         return true;
    209                 }
    210         } // namespace
    211 
    212         // used in resolveTypeof
    213         Expression * resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ) {
    214                 TypeEnvironment env;
    215                 return resolveInVoidContext( expr, indexer, env );
    216         }
    217 
    218         Expression * resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ) {
    219                 // it's a property of the language that a cast expression has either 1 or 0 interpretations; if it has 0
    220                 // interpretations, an exception has already been thrown.
    221                 assertf( expr, "expected a non-null expression." );
    222 
    223                 static CastExpr untyped( nullptr ); // cast to void
    224 
    225                 // set up and resolve expression cast to void
    226                 untyped.arg = expr;
    227                 Alternative choice;
    228                 findUnfinishedKindExpression( &untyped, choice, indexer, "", standardAlternativeFilter, true );
    229                 CastExpr * castExpr = strict_dynamic_cast< CastExpr * >( choice.expr );
    230                 env = std::move( choice.env );
    231 
    232                 // clean up resolved expression
    233                 Expression * ret = castExpr->arg;
    234                 castExpr->arg = nullptr;
    235 
    236                 // unlink the arg so that it isn't deleted twice at the end of the program
    237                 untyped.arg = nullptr;
    238                 return ret;
    239         }
    240 
    241132        void findVoidExpression( Expression *& untyped, const SymTab::Indexer &indexer ) {
    242133                resetTyVarRenaming();
    243134                TypeEnvironment env;
    244                 Expression * newExpr = resolveInVoidContext( untyped, indexer, env );
     135                Expression *newExpr = resolveInVoidContext( untyped, indexer, env );
    245136                finishExpr( newExpr, env, untyped->env );
    246137                delete untyped;
     
    249140
    250141        void findSingleExpression( Expression *&untyped, const SymTab::Indexer &indexer ) {
    251                 findKindExpression( untyped, indexer, "", standardAlternativeFilter );
     142                if ( ! untyped ) return;
     143                TypeEnvironment env;
     144                AlternativeFinder finder( indexer, env );
     145                finder.find( untyped );
     146                #if 0
     147                if ( finder.get_alternatives().size() != 1 ) {
     148                        std::cerr << "untyped expr is ";
     149                        untyped->print( std::cerr );
     150                        std::cerr << std::endl << "alternatives are:";
     151                        for ( const Alternative & alt : finder.get_alternatives() ) {
     152                                alt.print( std::cerr );
     153                        } // for
     154                } // if
     155                #endif
     156                assertf( finder.get_alternatives().size() == 1, "findSingleExpression: must have exactly one alternative at the end: (%zd) %s", finder.get_alternatives().size(), toString( untyped ).c_str() );
     157                Alternative &choice = finder.get_alternatives().front();
     158                Expression *newExpr = choice.expr->clone();
     159                finishExpr( newExpr, choice.env, untyped->env );
     160                delete untyped;
     161                untyped = newExpr;
    252162        }
    253163
     
    260170
    261171        namespace {
    262                 bool isIntegralType( const Alternative & alt ) {
    263                         Type * type = alt.expr->result;
     172                /// resolve `untyped` to the expression whose type satisfies `pred` with the lowest cost; kindStr is used for providing better error messages
     173                template<typename Pred>
     174                void findKindExpression(Expression *& untyped, const SymTab::Indexer & indexer, const std::string & kindStr, Pred pred) {
     175                        TypeEnvironment env;
     176                        AlternativeFinder finder( indexer, env );
     177                        finder.findWithAdjustment( untyped );
     178
     179                        AltList candidates;
     180                        for ( Alternative & alt : finder.get_alternatives() ) {
     181                                if ( pred( alt.expr->result ) ) {
     182                                        candidates.push_back( std::move( alt ) );
     183                                }
     184                        }
     185
     186                        // choose the lowest cost expression among the candidates
     187                        AltList winners;
     188                        findMinCost( candidates.begin(), candidates.end(), back_inserter( winners ) );
     189                        if ( winners.size() == 0 ) {
     190                                throw SemanticError( untyped, "No reasonable alternatives for " + kindStr + " expression: " );
     191                        } else if ( winners.size() != 1 ) {
     192                                std::ostringstream stream;
     193                                stream << "Cannot choose between " << winners.size() << " alternatives for " + kindStr +  " expression\n";
     194                                untyped->print( stream );
     195                                stream << "Alternatives are:\n";
     196                                printAlts( winners, stream, 1 );
     197                                throw SemanticError( untyped->location, stream.str() );
     198                        }
     199
     200                        // there is one unambiguous interpretation - move the expression into the with statement
     201                        Alternative & alt = winners.front();
     202                        finishExpr( alt.expr, alt.env, untyped->env );
     203                        delete untyped;
     204                        untyped = alt.expr;
     205                        alt.expr = nullptr;
     206                }
     207
     208                bool isIntegralType( Type *type ) {
    264209                        if ( dynamic_cast< EnumInstType * >( type ) ) {
    265210                                return true;
     
    614559                        if( func_candidates.size() > 1 ) { SemanticError top( stmt->location, "Ambiguous function in call to waitfor"            ); top.append( errors ); throw top; }
    615560                        if( args_candidates.size() > 1 ) { SemanticError top( stmt->location, "Ambiguous arguments in call to waitfor"           ); top.append( errors ); throw top; }
    616                         // TODO: need to use findDeletedExpr to ensure no deleted identifiers are used.
     561
    617562
    618563                        // Swap the results from the alternative with the unresolved values.
     
    647592        }
    648593
    649         bool isStructOrUnion( const Alternative & alt ) {
    650                 Type * t = alt.expr->result->stripReferences();
     594        bool isStructOrUnion( Type * t ) {
     595                t = t->stripReferences();
    651596                return dynamic_cast< StructInstType * >( t ) || dynamic_cast< UnionInstType * >( t );
    652597        }
  • src/ResolvExpr/Unify.cc

    r7c782af r62cd621  
    563563                        flatten( dcl->get_type(), back_inserter( types ) );
    564564                        for ( Type * t : types ) {
    565                                 // outermost const, volatile, _Atomic qualifiers in parameters should not play a role in the unification of function types, since they do not determine whether a function is callable.
    566                                 // Note: MUST consider at least mutex qualifier, since functions can be overloaded on outermost mutex and a mutex function has different requirements than a non-mutex function.
    567                                 t->get_qualifiers() -= Type::Qualifiers(Type::Const | Type::Volatile | Type::Atomic);
    568 
    569565                                dst.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::C, nullptr, t, nullptr ) );
    570566                        }
     
    584580
    585581                        // sizes don't have to match if ttypes are involved; need to be more precise wrt where the ttype is to prevent errors
    586                         if ( (flatFunc->parameters.size() == flatOther->parameters.size() && flatFunc->returnVals.size() == flatOther->returnVals.size()) || flatFunc->isTtype() || flatOther->isTtype() ) {
    587                                 if ( unifyDeclList( flatFunc->parameters.begin(), flatFunc->parameters.end(), flatOther->parameters.begin(), flatOther->parameters.end(), env, needAssertions, haveAssertions, openVars, indexer ) ) {
    588                                         if ( unifyDeclList( flatFunc->returnVals.begin(), flatFunc->returnVals.end(), flatOther->returnVals.begin(), flatOther->returnVals.end(), env, needAssertions, haveAssertions, openVars, indexer ) ) {
     582                        if ( (flatFunc->get_parameters().size() == flatOther->get_parameters().size() && flatFunc->get_returnVals().size() == flatOther->get_returnVals().size()) || flatFunc->isTtype() || flatOther->isTtype() ) {
     583                                if ( unifyDeclList( flatFunc->get_parameters().begin(), flatFunc->get_parameters().end(), flatOther->get_parameters().begin(), flatOther->get_parameters().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) {
     584                                        if ( unifyDeclList( flatFunc->get_returnVals().begin(), flatFunc->get_returnVals().end(), flatOther->get_returnVals().begin(), flatOther->get_returnVals().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) {
    589585
    590586                                                // the original types must be used in mark assertions, since pointer comparisons are used
     
    603599                // check that other type is compatible and named the same
    604600                RefType *otherStruct = dynamic_cast< RefType* >( other );
    605                 result = otherStruct && inst->name == otherStruct->name;
     601                result = otherStruct && inst->get_name() == otherStruct->get_name();
    606602        }
    607603
     
    612608                if ( ! result ) return;
    613609                // Check that parameters of types unify, if any
    614                 std::list< Expression* > params = inst->parameters;
    615                 std::list< Expression* > otherParams = ((RefType*)other)->parameters;
     610                std::list< Expression* > params = inst->get_parameters();
     611                std::list< Expression* > otherParams = ((RefType*)other)->get_parameters();
    616612
    617613                std::list< Expression* >::const_iterator it = params.begin(), jt = otherParams.begin();
  • src/SymTab/Autogen.cc

    r7c782af r62cd621  
    377377                        paramType->attributes.clear();
    378378                        // add a parameter corresponding to this field
    379                         ObjectDecl * param = new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType, nullptr );
    380                         cloneAll_if( field->attributes, param->attributes, [](Attribute * attr) { return attr->isValidOnFuncParam(); } );
    381                         memCtorType->parameters.push_back( param );
     379                        memCtorType->parameters.push_back( new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType, nullptr ) );
    382380                        FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting );
    383381                        makeFieldCtorBody( aggregateDecl->members.begin(), aggregateDecl->members.end(), ctor );
  • src/SymTab/FixFunction.cc

    r7c782af r62cd621  
    3636        }
    3737
    38         // xxx - this passes on void[], e.g.
    39         //   void foo(void [10]);
    40         // does not cause an error
    41 
    4238        Type * FixFunction::postmutate(ArrayType *arrayType) {
    4339                // need to recursively mutate the base type in order for multi-dimensional arrays to work.
     
    6662        void FixFunction::premutate(ZeroType *) { visit_children = false; }
    6763        void FixFunction::premutate(OneType *) { visit_children = false; }
    68 
    69         bool fixFunction( DeclarationWithType *& dwt ) {
    70                 PassVisitor<FixFunction> fixer;
    71                 dwt = dwt->acceptMutator( fixer );
    72                 return fixer.pass.isVoid;
    73         }
    7464} // namespace SymTab
    7565
  • src/SymTab/FixFunction.h

    r7c782af r62cd621  
    4747                bool isVoid;
    4848        };
    49 
    50         bool fixFunction( DeclarationWithType *& );
    5149} // namespace SymTab
    5250
  • src/SymTab/Indexer.cc

    r7c782af r62cd621  
    286286        }
    287287
    288         const Indexer::IdData * Indexer::lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) const {
    289                 if ( ! tables ) return nullptr;
    290                 if ( tables->scope < scope ) return nullptr;
     288        DeclarationWithType *Indexer::lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) const {
     289                if ( ! tables ) return 0;
     290                if ( tables->scope < scope ) return 0;
    291291
    292292                IdTable::const_iterator decls = tables->idTable.find( id );
     
    294294                        const MangleTable &mangleTable = decls->second;
    295295                        MangleTable::const_iterator decl = mangleTable.find( mangleName );
    296                         if ( decl != mangleTable.end() ) return &decl->second;
     296                        if ( decl != mangleTable.end() ) return decl->second.id;
    297297                }
    298298
    299299                return tables->base.lookupIdAtScope( id, mangleName, scope );
    300         }
    301 
    302         Indexer::IdData * Indexer::lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) {
    303                 return const_cast<IdData *>(const_cast<const Indexer *>(this)->lookupIdAtScope( id, mangleName, scope ));
    304300        }
    305301
     
    377373        }
    378374
    379         bool addedIdConflicts( Indexer::IdData & existing, DeclarationWithType *added, BaseSyntaxNode * deleteStmt, Indexer::ConflictFunction handleConflicts ) {
     375        bool addedIdConflicts( DeclarationWithType *existing, DeclarationWithType *added ) {
    380376                // if we're giving the same name mangling to things of different types then there is something wrong
    381                 assert( (dynamic_cast<ObjectDecl*>( added ) && dynamic_cast<ObjectDecl*>( existing.id ) )
    382                         || (dynamic_cast<FunctionDecl*>( added ) && dynamic_cast<FunctionDecl*>( existing.id ) ) );
    383 
    384                 if ( LinkageSpec::isOverridable( existing.id->get_linkage() ) ) {
     377                assert( (dynamic_cast<ObjectDecl*>( added ) && dynamic_cast<ObjectDecl*>( existing ) )
     378                        || (dynamic_cast<FunctionDecl*>( added ) && dynamic_cast<FunctionDecl*>( existing ) ) );
     379
     380                if ( LinkageSpec::isOverridable( existing->get_linkage() ) ) {
    385381                        // new definition shadows the autogenerated one, even at the same scope
    386382                        return false;
    387                 } else if ( LinkageSpec::isMangled( added->get_linkage() ) || ResolvExpr::typesCompatible( added->get_type(), existing.id->get_type(), Indexer() ) ) {
    388 
    389                         // it is a conflict if one declaration is deleted and the other is not
    390                         if ( deleteStmt && ! existing.deleteStmt ) {
    391                                 return handleConflicts( existing, "deletion of defined identifier " );
    392                         } else if ( ! deleteStmt && existing.deleteStmt ) {
    393                                 return handleConflicts( existing, "definition of deleted identifier " );
    394                         }
    395 
     383                } else if ( LinkageSpec::isMangled( added->get_linkage() ) || ResolvExpr::typesCompatible( added->get_type(), existing->get_type(), Indexer() ) ) {
    396384                        // typesCompatible doesn't really do the right thing here. When checking compatibility of function types,
    397385                        // we should ignore outermost pointer qualifiers, except _Atomic?
    398                         FunctionDecl * newentry = dynamic_cast< FunctionDecl * >( added );
    399                         FunctionDecl * oldentry = dynamic_cast< FunctionDecl * >( existing.id );
     386                        FunctionDecl *newentry = dynamic_cast< FunctionDecl* >( added );
     387                        FunctionDecl *oldentry = dynamic_cast< FunctionDecl* >( existing );
    400388                        if ( newentry && oldentry ) {
    401389                                if ( newentry->get_statements() && oldentry->get_statements() ) {
    402                                         return handleConflicts( existing, "duplicate function definition for " );
     390                                        throw SemanticError( added, "duplicate function definition for " );
    403391                                } // if
    404392                        } else {
     
    407395                                // xxx - perhaps it's actually if either is intrinsic then this is okay?
    408396                                //       might also need to be same storage class?
    409                                 ObjectDecl * newobj = dynamic_cast< ObjectDecl * >( added );
    410                                 ObjectDecl * oldobj = dynamic_cast< ObjectDecl * >( existing.id );
     397                                ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( added );
     398                                ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( existing );
    411399                                if ( ! newobj->get_storageClasses().is_extern && ! oldobj->get_storageClasses().is_extern ) {
    412                                         return handleConflicts( existing, "duplicate object definition for " );
     400                                        throw SemanticError( added, "duplicate object definition for " );
    413401                                } // if
    414402                        } // if
    415403                } else {
    416                         return handleConflicts( existing, "duplicate definition for " );
     404                        throw SemanticError( added, "duplicate definition for " );
    417405                } // if
    418406
     
    420408        }
    421409
    422         void Indexer::addId( DeclarationWithType *decl, ConflictFunction handleConflicts, Expression * baseExpr, BaseSyntaxNode * deleteStmt ) {
     410        void Indexer::addId( DeclarationWithType *decl, Expression * baseExpr ) {
    423411                if ( decl->name == "" ) return;
    424412                debugPrint( "Adding Id " << decl->name << std::endl );
     
    446434                        }
    447435                } else {
    448                         // Check that a Cforall declaration doesn't override any C declaration
     436                        // Check that a Cforall declaration doesn't overload any C declaration
    449437                        if ( hasCompatibleCDecl( name, mangleName, scope ) ) {
    450438                                throw SemanticError( decl, "Cforall declaration hides C function " );
     
    453441
    454442                // Skip repeat declarations of the same identifier
    455                 IdData * existing = lookupIdAtScope( name, mangleName, scope );
    456                 if ( existing && existing->id && addedIdConflicts( *existing, decl, deleteStmt, handleConflicts ) ) return;
     443                DeclarationWithType *existing = lookupIdAtScope( name, mangleName, scope );
     444                if ( existing && addedIdConflicts( existing, decl ) ) return;
    457445
    458446                // add to indexer
    459                 tables->idTable[ name ][ mangleName ] = { decl, baseExpr, deleteStmt };
     447                tables->idTable[ name ][ mangleName ] = { decl, baseExpr };
    460448                ++tables->size;
    461         }
    462 
    463         void Indexer::addId( DeclarationWithType * decl, Expression * baseExpr ) {
    464                 // default handling of conflicts is to raise an error
    465                 addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( decl, msg ); return true; }, baseExpr );
    466         }
    467 
    468         void Indexer::addDeletedId( DeclarationWithType * decl, BaseSyntaxNode * deleteStmt ) {
    469                 // default handling of conflicts is to raise an error
    470                 addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( decl, msg ); return true; }, nullptr, deleteStmt );
    471449        }
    472450
     
    595573        }
    596574
    597         void Indexer::addMembers( AggregateDecl * aggr, Expression * expr, ConflictFunction handleConflicts ) {
     575        void Indexer::addMembers( AggregateDecl * aggr, Expression * expr ) {
    598576                for ( Declaration * decl : aggr->members ) {
    599577                        if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
    600                                 addId( dwt, handleConflicts, expr );
     578                                addId( dwt, expr );
    601579                                if ( dwt->name == "" ) {
    602580                                        Type * t = dwt->get_type()->stripReferences();
     
    604582                                                Expression * base = expr->clone();
    605583                                                ResolvExpr::referenceToRvalueConversion( base );
    606                                                 addMembers( t->getAggr(), new MemberExpr( dwt, base ), handleConflicts );
     584                                                addMembers( t->getAggr(), new MemberExpr( dwt, base ) );
    607585                                        }
    608586                                }
     
    611589        }
    612590
    613         void Indexer::addWith( std::list< Expression * > & withExprs, BaseSyntaxNode * withStmt ) {
     591        void Indexer::addWith( std::list< Expression * > & withExprs ) {
    614592                for ( Expression * expr : withExprs ) {
    615593                        if ( expr->result ) {
     
    617595                                assertf( aggr, "WithStmt expr has non-aggregate type: %s", toString( expr->result ).c_str() );
    618596
    619                                 addMembers( aggr, expr, [withStmt](IdData & existing, const std::string &) {
    620                                         // on conflict, delete the identifier
    621                                         existing.deleteStmt = withStmt;
    622                                         return true;
    623                                 });
     597                                addMembers( aggr, expr );
    624598                        }
    625599                }
     
    680654
    681655        void Indexer::print( std::ostream &os, int indent ) const {
    682                 using std::cerr;
     656            using std::cerr;
    683657
    684658                if ( tables ) {
     
    706680
    707681        Expression * Indexer::IdData::combine() const {
    708                 Expression * ret = nullptr;
    709682                if ( baseExpr ) {
    710683                        Expression * base = baseExpr->clone();
    711684                        ResolvExpr::referenceToRvalueConversion( base );
    712                         ret = new MemberExpr( id, base );
     685                        Expression * ret = new MemberExpr( id, base );
    713686                        // xxx - this introduces hidden environments, for now remove them.
    714687                        // std::swap( base->env, ret->env );
    715688                        delete base->env;
    716689                        base->env = nullptr;
    717                 } else {
    718                         ret = new VariableExpr( id );
    719                 }
    720                 if ( deleteStmt ) ret = new DeletedExpr( ret, deleteStmt );
    721                 return ret;
     690                        return ret;
     691                } else {
     692                        return new VariableExpr( id );
     693                }
    722694        }
    723695} // namespace SymTab
  • src/SymTab/Indexer.h

    r7c782af r62cd621  
    1919#include <list>               // for list
    2020#include <string>             // for string
    21 #include <functional>         // for function
    2221
    2322#include "SynTree/Visitor.h"  // for Visitor
     
    4140
    4241                struct IdData {
    43                         DeclarationWithType * id = nullptr;
    44                         Expression * baseExpr = nullptr; // WithExpr
    45 
    46                         /// non-null if this declaration is deleted
    47                         BaseSyntaxNode * deleteStmt = nullptr;
     42                        DeclarationWithType * id;
     43                        Expression * baseExpr; // WithExpr
    4844
    4945                        Expression * combine() const;
     
    6662
    6763                /// looks up a specific mangled ID at the given scope
    68                 IdData * lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope );
    69                 const IdData * lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
     64                DeclarationWithType *lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
    7065                /// returns true if there exists a declaration with C linkage and the given name with a different mangled name
    7166                bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
     
    7974                TraitDecl *lookupTraitAtScope( const std::string &id, unsigned long scope ) const;
    8075
    81                 typedef std::function<bool(IdData &, const std::string &)> ConflictFunction;
    82 
    83                 void addId( DeclarationWithType * decl, Expression * baseExpr = nullptr );
    84                 void addDeletedId( DeclarationWithType * decl, BaseSyntaxNode * deleteStmt );
    85 
     76                void addId( DeclarationWithType *decl, Expression * baseExpr = nullptr );
    8677                void addType( NamedTypeDecl *decl );
    8778                void addStruct( const std::string &id );
     
    9384
    9485                /// adds all of the IDs from WithStmt exprs
    95                 void addWith( std::list< Expression * > & withExprs, BaseSyntaxNode * withStmt );
     86                void addWith( std::list< Expression * > & withExprs );
    9687
    9788                /// adds all of the members of the Aggregate (addWith helper)
    98                 void addMembers( AggregateDecl * aggr, Expression * expr, ConflictFunction );
     89                void addMembers( AggregateDecl * aggr, Expression * expr );
    9990
    10091                /// convenience function for adding a list of Ids to the indexer
     
    126117                /// Ensures that tables variable is writable (i.e. allocated, uniquely owned by this Indexer, and at the current scope)
    127118                void makeWritable();
    128 
    129                 /// common code for addId, addDeletedId, etc.
    130                 void addId( DeclarationWithType * decl, ConflictFunction, Expression * baseExpr = nullptr, BaseSyntaxNode * deleteStmt = nullptr );
    131119        };
    132120} // namespace SymTab
  • src/SymTab/Mangler.cc

    r7c782af r62cd621  
    3737                        struct Mangler : public WithShortCircuiting, public WithVisitorRef<Mangler> {
    3838                                Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams );
    39                                 Mangler( const Mangler & ) = delete;
     39                                Mangler( const Mangler & );
    4040
    4141                                void previsit( BaseSyntaxNode * ) { visit_children = false; }
  • src/SymTab/Validate.cc

    r7c782af r62cd621  
    351351        namespace {
    352352                template< typename DWTList >
    353                 void fixFunctionList( DWTList & dwts, bool isVarArgs, FunctionType * func ) {
    354                         auto nvals = dwts.size();
    355                         bool containsVoid = false;
    356                         for ( auto & dwt : dwts ) {
    357                                 // fix each DWT and record whether a void was found
    358                                 containsVoid |= fixFunction( dwt );
    359                         }
    360 
    361                         // the only case in which "void" is valid is where it is the only one in the list
    362                         if ( containsVoid && ( nvals > 1 || isVarArgs ) ) {
    363                                 throw SemanticError( func, "invalid type void in function type " );
    364                         }
    365 
    366                         // one void is the only thing in the list; remove it.
    367                         if ( containsVoid ) {
    368                                 delete dwts.front();
    369                                 dwts.clear();
    370                         }
     353                void fixFunctionList( DWTList & dwts, FunctionType * func ) {
     354                        // the only case in which "void" is valid is where it is the only one in the list; then it should be removed
     355                        // entirely. other fix ups are handled by the FixFunction class
     356                        typedef typename DWTList::iterator DWTIterator;
     357                        DWTIterator begin( dwts.begin() ), end( dwts.end() );
     358                        if ( begin == end ) return;
     359                        PassVisitor<FixFunction> fixer;
     360                        DWTIterator i = begin;
     361                        *i = (*i)->acceptMutator( fixer );
     362                        if ( fixer.pass.isVoid ) {
     363                                DWTIterator j = i;
     364                                ++i;
     365                                delete *j;
     366                                dwts.erase( j );
     367                                if ( i != end ) {
     368                                        throw SemanticError( func, "invalid type void in function type " );
     369                                } // if
     370                        } else {
     371                                ++i;
     372                                for ( ; i != end; ++i ) {
     373                                        PassVisitor<FixFunction> fixer;
     374                                        *i = (*i)->acceptMutator( fixer );
     375                                        if ( fixer.pass.isVoid ) {
     376                                                throw SemanticError( func, "invalid type void in function type " );
     377                                        } // if
     378                                } // for
     379                        } // if
    371380                }
    372381        }
     
    374383        void EnumAndPointerDecay::previsit( FunctionType *func ) {
    375384                // Fix up parameters and return types
    376                 fixFunctionList( func->parameters, func->isVarArgs, func );
    377                 fixFunctionList( func->returnVals, false, func );
     385                fixFunctionList( func->get_parameters(), func );
     386                fixFunctionList( func->get_returnVals(), func );
    378387        }
    379388
     
    617626                        // apply FixFunction to every assertion to check for invalid void type
    618627                        for ( DeclarationWithType *& assertion : type->assertions ) {
    619                                 bool isVoid = fixFunction( assertion );
    620                                 if ( isVoid ) {
     628                                PassVisitor<FixFunction> fixer;
     629                                assertion = assertion->acceptMutator( fixer );
     630                                if ( fixer.pass.isVoid ) {
    621631                                        throw SemanticError( node, "invalid type void in assertion of function " );
    622632                                } // if
  • src/SynTree/Attribute.cc

    r7c782af r62cd621  
    1515
    1616#include <ostream>           // for operator<<, ostream, basic_ostream, endl
    17 #include <set>
    1817
    1918#include "Attribute.h"
     
    2221
    2322Attribute::Attribute( const Attribute &other ) : name( other.name ) {
    24         cloneAll( other.parameters, parameters );
     23  cloneAll( other.parameters, parameters );
    2524}
    2625
    2726Attribute::~Attribute() {
    28         deleteAll( parameters );
    29 }
    30 
    31 bool Attribute::isValidOnFuncParam() const {
    32         // attributes such as aligned, cleanup, etc. produce GCC errors when they appear
    33         // on function parameters. Maintain here a whitelist of attribute names that are
    34         // allowed to appear on parameters.
    35         static std::set< std::string > valid = {
    36                 "noreturn", "unused"
    37         };
    38         return valid.count( normalizedName() );
    39 }
    40 
    41 std::string Attribute::normalizedName() const {
    42         // trim beginning/ending _, convert to lowercase
    43         auto begin = name.find_first_not_of('_');
    44         auto end = name.find_last_not_of('_');
    45         if (begin == std::string::npos || end == std::string::npos) return "";
    46         std::string ret;
    47         ret.reserve( end-begin+1 );
    48         std::transform( &name[begin], &name[end+1], back_inserter( ret ), tolower );
    49         return ret;
     27  deleteAll( parameters );
    5028}
    5129
    5230void Attribute::print( std::ostream &os, Indenter indent ) const {
    53         using std::endl;
    54         using std::string;
     31  using std::endl;
     32  using std::string;
    5533
    56         if ( ! empty() ) {
    57                 os << "Attribute with name: " << name;
    58                 if ( ! parameters.empty() ) {
    59                         os << " with parameters: " << endl;
    60                         printAll( parameters, os, indent+1 );
    61                 }
    62         }
     34  if ( ! empty() ) {
     35    os << "Attribute with name: " << name;
     36    if ( ! parameters.empty() ) {
     37      os << " with parameters: " << endl;
     38      printAll( parameters, os, indent+1 );
     39    }
     40  }
    6341}
    6442
  • src/SynTree/Attribute.h

    r7c782af r62cd621  
    4343        bool empty() const { return name == ""; }
    4444
    45         std::string normalizedName() const;
    46 
    47         /// true if this attribute is allowed to appear attached to a function parameter
    48         bool isValidOnFuncParam() const;
    49 
    5045        Attribute * clone() const override { return new Attribute( *this ); }
    5146        virtual void accept( Visitor & v ) override { v.visit( this ); }
  • src/SynTree/Expression.cc

    r7c782af r62cd621  
    710710}
    711711
    712 DeletedExpr::DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt ) : expr( expr ), deleteStmt( deleteStmt ) {
    713         assert( expr->result );
    714         result = expr->result->clone();
    715 }
    716 DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {}
    717 DeletedExpr::~DeletedExpr() {
    718         delete expr;
    719 }
    720 
    721 void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
    722         os << "Deleted Expression" << std::endl << indent+1;
    723         expr->print( os, indent+1 );
    724         os << std::endl << indent+1 << "... deleted by: ";
    725         deleteStmt->print( os, indent+1 );
    726 }
    727 
    728 
    729712// Local Variables: //
    730713// tab-width: 4 //
  • src/SynTree/Expression.h

    r7c782af r62cd621  
    822822};
    823823
    824 /// expression that contains a deleted identifier - should never make it past the resolver.
    825 class DeletedExpr : public Expression {
    826 public:
    827         Expression * expr;
    828         BaseSyntaxNode * deleteStmt;
    829 
    830         DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt );
    831         DeletedExpr( const DeletedExpr & other );
    832         ~DeletedExpr();
    833 
    834         virtual DeletedExpr * clone() const { return new DeletedExpr( * this ); }
    835         virtual void accept( Visitor & v ) { v.visit( this ); }
    836         virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    837         virtual void print( std::ostream & os, Indenter indent = {} ) const;
    838 };
    839 
    840824// Local Variables: //
    841825// tab-width: 4 //
  • src/SynTree/Mutator.h

    r7c782af r62cd621  
    5555        virtual Statement * mutate( ImplicitCtorDtorStmt * impCtorDtorStmt );
    5656
    57         virtual Expression * mutate( ApplicationExpr * applicationExpr );
    58         virtual Expression * mutate( UntypedExpr * untypedExpr );
    59         virtual Expression * mutate( NameExpr * nameExpr );
    60         virtual Expression * mutate( AddressExpr * castExpr );
    61         virtual Expression * mutate( LabelAddressExpr * labAddressExpr );
    62         virtual Expression * mutate( CastExpr * castExpr );
    63         virtual Expression * mutate( VirtualCastExpr * castExpr );
    64         virtual Expression * mutate( UntypedMemberExpr * memberExpr );
    65         virtual Expression * mutate( MemberExpr * memberExpr );
    66         virtual Expression * mutate( VariableExpr * variableExpr );
    67         virtual Expression * mutate( ConstantExpr * constantExpr );
    68         virtual Expression * mutate( SizeofExpr * sizeofExpr );
    69         virtual Expression * mutate( AlignofExpr * alignofExpr );
    70         virtual Expression * mutate( UntypedOffsetofExpr * offsetofExpr );
    71         virtual Expression * mutate( OffsetofExpr * offsetofExpr );
    72         virtual Expression * mutate( OffsetPackExpr * offsetPackExpr );
    73         virtual Expression * mutate( AttrExpr * attrExpr );
    74         virtual Expression * mutate( LogicalExpr * logicalExpr );
    75         virtual Expression * mutate( ConditionalExpr * conditionalExpr );
    76         virtual Expression * mutate( CommaExpr * commaExpr );
    77         virtual Expression * mutate( TypeExpr * typeExpr );
    78         virtual Expression * mutate( AsmExpr * asmExpr );
    79         virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr );
    80         virtual Expression * mutate( ConstructorExpr * ctorExpr );
    81         virtual Expression * mutate( CompoundLiteralExpr * compLitExpr );
    82         virtual Expression * mutate( RangeExpr * rangeExpr );
    83         virtual Expression * mutate( UntypedTupleExpr * tupleExpr );
    84         virtual Expression * mutate( TupleExpr * tupleExpr );
    85         virtual Expression * mutate( TupleIndexExpr * tupleExpr );
    86         virtual Expression * mutate( TupleAssignExpr * assignExpr );
    87         virtual Expression * mutate( StmtExpr  * stmtExpr );
    88         virtual Expression * mutate( UniqueExpr  * uniqueExpr );
    89         virtual Expression * mutate( UntypedInitExpr  * initExpr );
    90         virtual Expression * mutate( InitExpr  * initExpr );
    91         virtual Expression * mutate( DeletedExpr * delExpr ) = 0;
     57        virtual Expression* mutate( ApplicationExpr * applicationExpr );
     58        virtual Expression* mutate( UntypedExpr * untypedExpr );
     59        virtual Expression* mutate( NameExpr * nameExpr );
     60        virtual Expression* mutate( AddressExpr * castExpr );
     61        virtual Expression* mutate( LabelAddressExpr * labAddressExpr );
     62        virtual Expression* mutate( CastExpr * castExpr );
     63        virtual Expression* mutate( VirtualCastExpr * castExpr );
     64        virtual Expression* mutate( UntypedMemberExpr * memberExpr );
     65        virtual Expression* mutate( MemberExpr * memberExpr );
     66        virtual Expression* mutate( VariableExpr * variableExpr );
     67        virtual Expression* mutate( ConstantExpr * constantExpr );
     68        virtual Expression* mutate( SizeofExpr * sizeofExpr );
     69        virtual Expression* mutate( AlignofExpr * alignofExpr );
     70        virtual Expression* mutate( UntypedOffsetofExpr * offsetofExpr );
     71        virtual Expression* mutate( OffsetofExpr * offsetofExpr );
     72        virtual Expression* mutate( OffsetPackExpr * offsetPackExpr );
     73        virtual Expression* mutate( AttrExpr * attrExpr );
     74        virtual Expression* mutate( LogicalExpr * logicalExpr );
     75        virtual Expression* mutate( ConditionalExpr * conditionalExpr );
     76        virtual Expression* mutate( CommaExpr * commaExpr );
     77        virtual Expression* mutate( TypeExpr * typeExpr );
     78        virtual Expression* mutate( AsmExpr * asmExpr );
     79        virtual Expression* mutate( ImplicitCopyCtorExpr * impCpCtorExpr );
     80        virtual Expression* mutate( ConstructorExpr * ctorExpr );
     81        virtual Expression* mutate( CompoundLiteralExpr * compLitExpr );
     82        virtual Expression* mutate( RangeExpr * rangeExpr );
     83        virtual Expression* mutate( UntypedTupleExpr * tupleExpr );
     84        virtual Expression* mutate( TupleExpr * tupleExpr );
     85        virtual Expression* mutate( TupleIndexExpr * tupleExpr );
     86        virtual Expression* mutate( TupleAssignExpr * assignExpr );
     87        virtual Expression* mutate( StmtExpr  * stmtExpr );
     88        virtual Expression* mutate( UniqueExpr  * uniqueExpr );
     89        virtual Expression* mutate( UntypedInitExpr  * initExpr );
     90        virtual Expression* mutate( InitExpr  * initExpr );
    9291
    9392        virtual Type * mutate( VoidType * basicType );
  • src/SynTree/Statement.cc

    r7c782af r62cd621  
    468468void WithStmt::print( std::ostream & os, Indenter indent ) const {
    469469        os << "With statement" << endl;
    470         os << indent << "... with expressions: " << endl;
    471         printAll( exprs, os, indent+1 );
    472470        os << indent << "... with statement:" << endl << indent+1;
    473471        stmt->print( os, indent+1 );
  • src/SynTree/SynTree.h

    r7c782af r62cd621  
    9797class UntypedInitExpr;
    9898class InitExpr;
    99 class DeletedExpr;
    10099
    101100class Type;
  • src/SynTree/Visitor.h

    r7c782af r62cd621  
    9191        virtual void visit( UntypedInitExpr *  initExpr );
    9292        virtual void visit( InitExpr *  initExpr );
    93         virtual void visit( DeletedExpr * delExpr ) = 0;
    9493
    9594        virtual void visit( VoidType * basicType );
  • src/Tuples/Explode.h

    r7c782af r62cd621  
    4343        /// Append alternative to an OutputIterator of Alternatives
    4444        template<typename OutputIterator>
    45         void append( OutputIterator out, Expression* expr, const ResolvExpr::TypeEnvironment& env,
     45        void append( OutputIterator out, Expression* expr, const ResolvExpr::TypeEnvironment& env, 
    4646                        const ResolvExpr::Cost& cost, const ResolvExpr::Cost& cvtCost ) {
    4747                *out++ = ResolvExpr::Alternative{ expr, env, cost, cvtCost };
     
    4949
    5050        /// Append alternative to an ExplodedActual
    51         static inline void append( ResolvExpr::ExplodedActual& ea, Expression* expr,
     51        static inline void append( ResolvExpr::ExplodedActual& ea, Expression* expr, 
    5252                        const ResolvExpr::TypeEnvironment&, const ResolvExpr::Cost&, const ResolvExpr::Cost& ) {
    5353                ea.exprs.emplace_back( expr );
     
    5757        /// helper function used by explode
    5858        template< typename Output >
    59         void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt,
     59        void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt, 
    6060                        const SymTab::Indexer & indexer, Output&& out, bool isTupleAssign ) {
    6161                if ( isTupleAssign ) {
     
    6363                        if ( CastExpr * castExpr = isReferenceCast( expr ) ) {
    6464                                ResolvExpr::AltList alts;
    65                                 explodeUnique(
     65                                explodeUnique( 
    6666                                        castExpr->get_arg(), alt, indexer, back_inserter( alts ), isTupleAssign );
    6767                                for ( ResolvExpr::Alternative & alt : alts ) {
    6868                                        // distribute reference cast over all components
    69                                         append( std::forward<Output>(out), distributeReference( alt.release_expr() ),
     69                                        append( std::forward<Output>(out), distributeReference( alt.release_expr() ), 
    7070                                                alt.env, alt.cost, alt.cvtCost );
    7171                                }
     
    108108        /// expands a tuple-valued alternative into multiple alternatives, each with a non-tuple-type
    109109        template< typename Output >
    110         void explode( const ResolvExpr::Alternative &alt, const SymTab::Indexer & indexer,
     110        void explode( const ResolvExpr::Alternative &alt, const SymTab::Indexer & indexer, 
    111111                        Output&& out, bool isTupleAssign = false ) {
    112112                explodeUnique( alt.expr, alt, indexer, std::forward<Output>(out), isTupleAssign );
     
    115115        // explode list of alternatives
    116116        template< typename AltIterator, typename Output >
    117         void explode( AltIterator altBegin, AltIterator altEnd, const SymTab::Indexer & indexer,
     117        void explode( AltIterator altBegin, AltIterator altEnd, const SymTab::Indexer & indexer, 
    118118                        Output&& out, bool isTupleAssign = false ) {
    119119                for ( ; altBegin != altEnd; ++altBegin ) {
     
    123123
    124124        template< typename Output >
    125         void explode( const ResolvExpr::AltList & alts, const SymTab::Indexer & indexer, Output&& out,
     125        void explode( const ResolvExpr::AltList & alts, const SymTab::Indexer & indexer, Output&& out, 
    126126                        bool isTupleAssign = false ) {
    127127                explode( alts.begin(), alts.end(), indexer, std::forward<Output>(out), isTupleAssign );
  • src/libcfa/assert.c

    r7c782af r62cd621  
    2222        extern const char * __progname;                                         // global name of running executable (argv[0])
    2323
    24         #define CFA_ASSERT_FMT "Cforall Assertion error \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\""
     24        #define CFA_ASSERT_FMT "Cforall Assertion error from program \"%s\" in \"%s\" at line %d in file \"%s\""
    2525
    2626        // called by macro assert in assert.h
    2727        void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
    28                 __cfaabi_dbg_bits_print_safe( CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
     28                __cfaabi_dbg_bits_print_safe( CFA_ASSERT_FMT ".\n", __progname, function, line, file );
    2929                abort();
    3030        }
     
    3333        void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
    3434                __cfaabi_dbg_bits_acquire();
    35                 __cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
     35                __cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", __progname, function, line, file );
    3636
    3737                va_list args;
  • src/tests/.expect/attributes.x64.txt

    r7c782af r62cd621  
    6363static inline void ___destructor__F_R4sFdl_autogen___1(struct Fdl *___dst__R4sFdl_1);
    6464static inline struct Fdl ___operator_assign__F4sFdl_R4sFdl4sFdl_autogen___1(struct Fdl *___dst__R4sFdl_1, struct Fdl ___src__4sFdl_1);
    65 static inline void ___constructor__F_R4sFdli_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1);
    66 static inline void ___constructor__F_R4sFdlii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1);
    67 static inline void ___constructor__F_R4sFdliii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1);
    68 static inline void ___constructor__F_R4sFdliiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1);
    69 static inline void ___constructor__F_R4sFdliiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1);
    70 static inline void ___constructor__F_R4sFdliiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1, signed int __f6__i_1);
    71 static inline void ___constructor__F_R4sFdliiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1, signed int __f6__i_1, __attribute__ ((unused,unused)) signed int __f7__i_1);
    72 static inline void ___constructor__F_R4sFdliiiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1, signed int __f6__i_1, __attribute__ ((unused,unused)) signed int __f7__i_1, __attribute__ ((unused)) signed int __f8__i_1);
    73 static inline void ___constructor__F_R4sFdliiiiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1, signed int __f6__i_1, __attribute__ ((unused,unused)) signed int __f7__i_1, __attribute__ ((unused)) signed int __f8__i_1, __attribute__ ((unused)) signed int __anonymous_object1);
    74 static inline void ___constructor__F_R4sFdliiiiiiiiiPi_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1, signed int __f6__i_1, __attribute__ ((unused,unused)) signed int __f7__i_1, __attribute__ ((unused)) signed int __f8__i_1, __attribute__ ((unused)) signed int __anonymous_object2, __attribute__ ((unused,unused)) signed int *__f9__Pi_1);
     65static inline void ___constructor__F_R4sFdli_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1);
     66static inline void ___constructor__F_R4sFdlii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1);
     67static inline void ___constructor__F_R4sFdliii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1);
     68static inline void ___constructor__F_R4sFdliiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1);
     69static inline void ___constructor__F_R4sFdliiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1);
     70static inline void ___constructor__F_R4sFdliiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1, signed int __f6__i_1);
     71static inline void ___constructor__F_R4sFdliiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1, signed int __f6__i_1, signed int __f7__i_1);
     72static inline void ___constructor__F_R4sFdliiiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1, signed int __f6__i_1, signed int __f7__i_1, signed int __f8__i_1);
     73static inline void ___constructor__F_R4sFdliiiiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1, signed int __f6__i_1, signed int __f7__i_1, signed int __f8__i_1, signed int __anonymous_object1);
     74static inline void ___constructor__F_R4sFdliiiiiiiiiPi_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1, signed int __f6__i_1, signed int __f7__i_1, signed int __f8__i_1, signed int __anonymous_object2, signed int *__f9__Pi_1);
    7575static inline void ___constructor__F_R4sFdl_autogen___1(struct Fdl *___dst__R4sFdl_1){
    7676    ((void)((*___dst__R4sFdl_1).__f1__i_1) /* ?{} */);
     
    124124    return ___ret__4sFdl_1;
    125125}
    126 static inline void ___constructor__F_R4sFdli_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1){
     126static inline void ___constructor__F_R4sFdli_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1){
    127127    ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
    128128    ((void)((*___dst__R4sFdl_1).__f2__i_1) /* ?{} */);
     
    136136    ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */);
    137137}
    138 static inline void ___constructor__F_R4sFdlii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1){
     138static inline void ___constructor__F_R4sFdlii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1){
    139139    ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
    140140    ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */);
     
    148148    ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */);
    149149}
    150 static inline void ___constructor__F_R4sFdliii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1){
     150static inline void ___constructor__F_R4sFdliii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1){
    151151    ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
    152152    ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */);
     
    160160    ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */);
    161161}
    162 static inline void ___constructor__F_R4sFdliiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1){
     162static inline void ___constructor__F_R4sFdliiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1){
    163163    ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
    164164    ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */);
     
    172172    ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */);
    173173}
    174 static inline void ___constructor__F_R4sFdliiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1){
    175     ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
    176     ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */);
    177     ((void)((*___dst__R4sFdl_1).__f3__i_1=__f3__i_1) /* ?{} */);
    178     ((void)((*___dst__R4sFdl_1).__f4__i_1=__f4__i_1) /* ?{} */);
    179     ((void)((*___dst__R4sFdl_1).__f5__i_1=__f5__i_1) /* ?{} */);
    180     ((void)((*___dst__R4sFdl_1).__f6__i_1) /* ?{} */);
    181     ((void)((*___dst__R4sFdl_1).__f7__i_1) /* ?{} */);
    182     ((void)((*___dst__R4sFdl_1).__f8__i_1) /* ?{} */);
    183     ((void)((*___dst__R4sFdl_1).__anonymous_object0) /* ?{} */);
    184     ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */);
    185 }
    186 static inline void ___constructor__F_R4sFdliiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1, signed int __f6__i_1){
     174static inline void ___constructor__F_R4sFdliiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1){
     175    ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
     176    ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */);
     177    ((void)((*___dst__R4sFdl_1).__f3__i_1=__f3__i_1) /* ?{} */);
     178    ((void)((*___dst__R4sFdl_1).__f4__i_1=__f4__i_1) /* ?{} */);
     179    ((void)((*___dst__R4sFdl_1).__f5__i_1=__f5__i_1) /* ?{} */);
     180    ((void)((*___dst__R4sFdl_1).__f6__i_1) /* ?{} */);
     181    ((void)((*___dst__R4sFdl_1).__f7__i_1) /* ?{} */);
     182    ((void)((*___dst__R4sFdl_1).__f8__i_1) /* ?{} */);
     183    ((void)((*___dst__R4sFdl_1).__anonymous_object0) /* ?{} */);
     184    ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */);
     185}
     186static inline void ___constructor__F_R4sFdliiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1, signed int __f6__i_1){
    187187    ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
    188188    ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */);
     
    196196    ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */);
    197197}
    198 static inline void ___constructor__F_R4sFdliiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1, signed int __f6__i_1, __attribute__ ((unused,unused)) signed int __f7__i_1){
     198static inline void ___constructor__F_R4sFdliiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1, signed int __f6__i_1, signed int __f7__i_1){
    199199    ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
    200200    ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */);
     
    208208    ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */);
    209209}
    210 static inline void ___constructor__F_R4sFdliiiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1, signed int __f6__i_1, __attribute__ ((unused,unused)) signed int __f7__i_1, __attribute__ ((unused)) signed int __f8__i_1){
     210static inline void ___constructor__F_R4sFdliiiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1, signed int __f6__i_1, signed int __f7__i_1, signed int __f8__i_1){
    211211    ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
    212212    ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */);
     
    220220    ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */);
    221221}
    222 static inline void ___constructor__F_R4sFdliiiiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1, signed int __f6__i_1, __attribute__ ((unused,unused)) signed int __f7__i_1, __attribute__ ((unused)) signed int __f8__i_1, __attribute__ ((unused)) signed int __anonymous_object3){
     222static inline void ___constructor__F_R4sFdliiiiiiiii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1, signed int __f6__i_1, signed int __f7__i_1, signed int __f8__i_1, signed int __anonymous_object3){
    223223    ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
    224224    ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */);
     
    232232    ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */);
    233233}
    234 static inline void ___constructor__F_R4sFdliiiiiiiiiPi_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1, __attribute__ ((unused)) signed int __f2__i_1, __attribute__ ((unused,unused)) signed int __f3__i_1, __attribute__ ((unused)) signed int __f4__i_1, __attribute__ ((unused,unused)) signed int __f5__i_1, signed int __f6__i_1, __attribute__ ((unused,unused)) signed int __f7__i_1, __attribute__ ((unused)) signed int __f8__i_1, __attribute__ ((unused)) signed int __anonymous_object4, __attribute__ ((unused,unused)) signed int *__f9__Pi_1){
     234static inline void ___constructor__F_R4sFdliiiiiiiiiPi_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1, signed int __f2__i_1, signed int __f3__i_1, signed int __f4__i_1, signed int __f5__i_1, signed int __f6__i_1, signed int __f7__i_1, signed int __f8__i_1, signed int __anonymous_object4, signed int *__f9__Pi_1){
    235235    ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */);
    236236    ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */);
     
    371371static inline void ___destructor__F_R4sVad_autogen___1(struct Vad *___dst__R4sVad_1);
    372372static inline struct Vad ___operator_assign__F4sVad_R4sVad4sVad_autogen___1(struct Vad *___dst__R4sVad_1, struct Vad ___src__4sVad_1);
    373 static inline void ___constructor__F_R4sVadi_autogen___1(struct Vad *___dst__R4sVad_1, __attribute__ ((unused)) signed int __anonymous_object36);
    374 static inline void ___constructor__F_R4sVadiPi_autogen___1(struct Vad *___dst__R4sVad_1, __attribute__ ((unused)) signed int __anonymous_object37, __attribute__ ((unused,unused)) signed int *__anonymous_object38);
    375 static inline void ___constructor__F_R4sVadiPiA0i_autogen___1(struct Vad *___dst__R4sVad_1, __attribute__ ((unused)) signed int __anonymous_object39, __attribute__ ((unused,unused)) signed int *__anonymous_object40, __attribute__ ((unused,unused)) signed int __anonymous_object41[((unsigned long int )10)]);
    376 static inline void ___constructor__F_R4sVadiPiA0iPFi___autogen___1(struct Vad *___dst__R4sVad_1, __attribute__ ((unused)) signed int __anonymous_object42, __attribute__ ((unused,unused)) signed int *__anonymous_object43, __attribute__ ((unused,unused)) signed int __anonymous_object44[((unsigned long int )10)], __attribute__ ((unused,unused)) signed int (*__anonymous_object45)());
     373static inline void ___constructor__F_R4sVadi_autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object36);
     374static inline void ___constructor__F_R4sVadiPi_autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object37, signed int *__anonymous_object38);
     375static inline void ___constructor__F_R4sVadiPiA0i_autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object39, signed int *__anonymous_object40, signed int __anonymous_object41[((unsigned long int )10)]);
     376static inline void ___constructor__F_R4sVadiPiA0iPFi___autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object42, signed int *__anonymous_object43, signed int __anonymous_object44[((unsigned long int )10)], signed int (*__anonymous_object45)());
    377377static inline void ___constructor__F_R4sVad_autogen___1(struct Vad *___dst__R4sVad_1){
    378378    ((void)((*___dst__R4sVad_1).__anonymous_object32) /* ?{} */);
     
    430430    return ___ret__4sVad_1;
    431431}
    432 static inline void ___constructor__F_R4sVadi_autogen___1(struct Vad *___dst__R4sVad_1, __attribute__ ((unused)) signed int __anonymous_object46){
     432static inline void ___constructor__F_R4sVadi_autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object46){
    433433    ((void)((*___dst__R4sVad_1).__anonymous_object32=__anonymous_object46) /* ?{} */);
    434434    ((void)((*___dst__R4sVad_1).__anonymous_object33) /* ?{} */);
     
    443443    ((void)((*___dst__R4sVad_1).__anonymous_object35) /* ?{} */);
    444444}
    445 static inline void ___constructor__F_R4sVadiPi_autogen___1(struct Vad *___dst__R4sVad_1, __attribute__ ((unused)) signed int __anonymous_object47, __attribute__ ((unused,unused)) signed int *__anonymous_object48){
     445static inline void ___constructor__F_R4sVadiPi_autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object47, signed int *__anonymous_object48){
    446446    ((void)((*___dst__R4sVad_1).__anonymous_object32=__anonymous_object47) /* ?{} */);
    447447    ((void)((*___dst__R4sVad_1).__anonymous_object33=__anonymous_object48) /* ?{} */);
     
    456456    ((void)((*___dst__R4sVad_1).__anonymous_object35) /* ?{} */);
    457457}
    458 static inline void ___constructor__F_R4sVadiPiA0i_autogen___1(struct Vad *___dst__R4sVad_1, __attribute__ ((unused)) signed int __anonymous_object49, __attribute__ ((unused,unused)) signed int *__anonymous_object50, __attribute__ ((unused,unused)) signed int __anonymous_object51[((unsigned long int )10)]){
     458static inline void ___constructor__F_R4sVadiPiA0i_autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object49, signed int *__anonymous_object50, signed int __anonymous_object51[((unsigned long int )10)]){
    459459    ((void)((*___dst__R4sVad_1).__anonymous_object32=__anonymous_object49) /* ?{} */);
    460460    ((void)((*___dst__R4sVad_1).__anonymous_object33=__anonymous_object50) /* ?{} */);
     
    469469    ((void)((*___dst__R4sVad_1).__anonymous_object35) /* ?{} */);
    470470}
    471 static inline void ___constructor__F_R4sVadiPiA0iPFi___autogen___1(struct Vad *___dst__R4sVad_1, __attribute__ ((unused)) signed int __anonymous_object52, __attribute__ ((unused,unused)) signed int *__anonymous_object53, __attribute__ ((unused,unused)) signed int __anonymous_object54[((unsigned long int )10)], __attribute__ ((unused,unused)) signed int (*__anonymous_object55)()){
     471static inline void ___constructor__F_R4sVadiPiA0iPFi___autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object52, signed int *__anonymous_object53, signed int __anonymous_object54[((unsigned long int )10)], signed int (*__anonymous_object55)()){
    472472    ((void)((*___dst__R4sVad_1).__anonymous_object32=__anonymous_object52) /* ?{} */);
    473473    ((void)((*___dst__R4sVad_1).__anonymous_object33=__anonymous_object53) /* ?{} */);
  • src/tests/tuple/tupleVariadic.c

    r7c782af r62cd621  
    9595}
    9696
    97 forall(ttype T | { void foo(T); }) void bar(T x) {}
    98 void foo(int) {}
    99 
    10097int main() {
    10198        array * x0 = new();
     
    120117        func(3, 2.0, 111, 4.145);
    121118        printf("finished func\n");
    122 
    123         {
    124                 // T = [const int] -- this ensures that void(*)(int) satisfies void(*)(const int)
    125                 const int x;
    126                 bar(x);
    127         }
    128119}
    129120
Note: See TracChangeset for help on using the changeset viewer.