Changes in / [62cd621:7c782af]
- Location:
- src
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r62cd621 r7c782af 764 764 765 765 void CodeGenerator::postvisit( StmtExpr * stmtExpr ) { 766 std::list< Statement * > & stmts = stmtExpr-> get_statements()->get_kids();766 std::list< Statement * > & stmts = stmtExpr->statements->kids; 767 767 output << "({" << endl; 768 768 ++indent; … … 775 775 // cannot cast to void, otherwise the expression statement has no value 776 776 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) { 777 exprStmt-> get_expr()->accept( *visitor );777 exprStmt->expr->accept( *visitor ); 778 778 output << ";" << endl; 779 779 ++i; … … 795 795 assertf( ! genC, "Unique expressions should not reach code generation." ); 796 796 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 ); 797 802 } 798 803 -
src/CodeGen/CodeGenerator.h
r62cd621 r7c782af 88 88 void postvisit( StmtExpr * ); 89 89 void postvisit( ConstructorExpr * ); 90 void postvisit( DeletedExpr * ); 90 91 91 92 //*** Statements -
src/Common/PassVisitor.h
r62cd621 r7c782af 121 121 virtual void visit( UntypedInitExpr * initExpr ) override final; 122 122 virtual void visit( InitExpr * initExpr ) override final; 123 virtual void visit( DeletedExpr * delExpr ) override final; 123 124 124 125 virtual void visit( VoidType * basicType ) override final; … … 215 216 virtual Expression * mutate( UntypedInitExpr * initExpr ) override final; 216 217 virtual Expression * mutate( InitExpr * initExpr ) override final; 218 virtual Expression * mutate( DeletedExpr * delExpr ) override final; 217 219 218 220 virtual Type * mutate( VoidType * basicType ) override final; … … 303 305 void indexerAddUnionFwd ( UnionDecl * node ) { indexer_impl_addUnionFwd ( pass, 0, node ); } 304 306 void indexerAddTrait ( TraitDecl * node ) { indexer_impl_addTrait ( pass, 0, node ); } 305 void indexerAddWith ( std::list< Expression * > & exprs ) { indexer_impl_addWith ( pass, 0, exprs); }307 void indexerAddWith ( std::list< Expression * > & exprs, BaseSyntaxNode * withStmt ) { indexer_impl_addWith ( pass, 0, exprs, withStmt ); } 306 308 307 309 -
src/Common/PassVisitor.impl.h
r62cd621 r7c782af 393 393 // shadow with exprs and not the other way around. 394 394 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 395 indexerAddWith( node->withExprs );395 indexerAddWith( node->withExprs, node ); 396 396 { 397 397 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); … … 423 423 // shadow with exprs and not the other way around. 424 424 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 425 indexerAddWith( node->withExprs );425 indexerAddWith( node->withExprs, node ); 426 426 { 427 427 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); … … 1064 1064 // catch statements introduce a level of scope (for the caught exception) 1065 1065 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1066 indexerAddWith( node->exprs );1066 indexerAddWith( node->exprs, node ); 1067 1067 maybeAccept_impl( node->stmt, *this ); 1068 1068 } … … 1077 1077 // catch statements introduce a level of scope (for the caught exception) 1078 1078 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1079 indexerAddWith( node->exprs );1079 indexerAddWith( node->exprs, node ); 1080 1080 maybeMutate_impl( node->stmt, *this ); 1081 1081 } … … 1971 1971 } 1972 1972 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 1973 1998 template< typename pass_type > 1974 1999 void PassVisitor< pass_type >::visit( VoidType * node ) { -
src/Common/PassVisitor.proto.h
r62cd621 r7c782af 193 193 194 194 195 #define INDEXER_FUNC ( func, type ) \195 #define INDEXER_FUNC1( func, type ) \ 196 196 template<typename pass_type> \ 197 197 static inline auto indexer_impl_##func ( pass_type & pass, int, type arg ) -> decltype( pass.indexer.func( arg ), void() ) { \ … … 202 202 static inline void indexer_impl_##func ( pass_type &, long, type ) { } \ 203 203 204 INDEXER_FUNC( addId , DeclarationWithType * ); 205 INDEXER_FUNC( addType , NamedTypeDecl * ); 206 INDEXER_FUNC( addStruct , StructDecl * ); 207 INDEXER_FUNC( addEnum , EnumDecl * ); 208 INDEXER_FUNC( addUnion , UnionDecl * ); 209 INDEXER_FUNC( addTrait , TraitDecl * ); 210 INDEXER_FUNC( addWith , std::list< Expression * > & ); 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 * ); 211 221 212 222 -
src/Common/utility.h
r62cd621 r7c782af 98 98 } 99 99 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 100 110 template< typename Container > 101 111 void assertAll( const Container &container ) { -
src/ResolvExpr/Alternative.h
r62cd621 r7c782af 57 57 /// Moves all elements from src to the beginning of dst 58 58 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 } 59 64 } // namespace ResolvExpr 60 65 -
src/ResolvExpr/AlternativeFinder.cc
r62cd621 r7c782af 95 95 void postvisit( StmtExpr * stmtExpr ); 96 96 void postvisit( UntypedInitExpr * initExpr ); 97 void postvisit( InitExpr * initExpr ); 98 void postvisit( DeletedExpr * delExpr ); 97 99 98 100 /// Adds alternatives for anonymous members … … 120 122 Type *& targetType; 121 123 }; 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 0130 // 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 }137 124 138 125 Cost sumCost( const AltList &in ) { … … 1380 1367 void AlternativeFinder::Finder::postvisit( NameExpr *nameExpr ) { 1381 1368 std::list< SymTab::Indexer::IdData > declList; 1382 indexer.lookupId( nameExpr-> get_name(), declList );1383 PRINT( std::cerr << "nameExpr is " << nameExpr-> get_name()<< std::endl; )1369 indexer.lookupId( nameExpr->name, declList ); 1370 PRINT( std::cerr << "nameExpr is " << nameExpr->name << std::endl; ) 1384 1371 for ( auto & data : declList ) { 1385 1372 Expression * newExpr = data.combine(); … … 1402 1389 // not sufficient to clone here, because variable's type may have changed 1403 1390 // since the VariableExpr was originally created. 1404 alternatives.push_back( Alternative( new VariableExpr( variableExpr-> get_var()), env, Cost::zero ) );1391 alternatives.push_back( Alternative( new VariableExpr( variableExpr->var ), env, Cost::zero ) ); 1405 1392 } 1406 1393 … … 1469 1456 // xxx - resolveTypeof? 1470 1457 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( offsetofExpr->get_type() ) ) { 1471 addOffsetof( structInst, offsetofExpr-> get_member());1458 addOffsetof( structInst, offsetofExpr->member ); 1472 1459 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( offsetofExpr->get_type() ) ) { 1473 addOffsetof( unionInst, offsetofExpr-> get_member());1460 addOffsetof( unionInst, offsetofExpr->member ); 1474 1461 } 1475 1462 } … … 1548 1535 secondFinder.findWithAdjustment( logicalExpr->get_arg2() ); 1549 1536 if ( secondFinder.alternatives.empty() ) return; 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) {1537 for ( const Alternative & first : firstFinder.alternatives ) { 1538 for ( const Alternative & second : secondFinder.alternatives ) { 1552 1539 TypeEnvironment compositeEnv; 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 ) );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 ) ); 1558 1545 } 1559 1546 } … … 1605 1592 AlternativeFinder secondFinder( indexer, newEnv ); 1606 1593 secondFinder.findWithAdjustment( commaExpr->get_arg2() ); 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 ) );1594 for ( const Alternative & alt : secondFinder.alternatives ) { 1595 alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt.expr->clone() ), alt.env, alt.cost ) ); 1609 1596 } // for 1610 1597 delete newFirstArg; … … 1614 1601 // resolve low and high, accept alternatives whose low and high types unify 1615 1602 AlternativeFinder firstFinder( indexer, env ); 1616 firstFinder.findWithAdjustment( rangeExpr-> get_low());1603 firstFinder.findWithAdjustment( rangeExpr->low ); 1617 1604 if ( firstFinder.alternatives.empty() ) return; 1618 1605 AlternativeFinder secondFinder( indexer, env ); 1619 secondFinder.findWithAdjustment( rangeExpr-> get_high());1606 secondFinder.findWithAdjustment( rangeExpr->high ); 1620 1607 if ( secondFinder.alternatives.empty() ) return; 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) {1608 for ( const Alternative & first : firstFinder.alternatives ) { 1609 for ( const Alternative & second : secondFinder.alternatives ) { 1623 1610 TypeEnvironment compositeEnv; 1624 compositeEnv.simpleCombine( first ->env );1625 compositeEnv.simpleCombine( second ->env );1611 compositeEnv.simpleCombine( first.env ); 1612 compositeEnv.simpleCombine( second.env ); 1626 1613 OpenVarSet openVars; 1627 1614 AssertionSet needAssertions, haveAssertions; 1628 Alternative newAlt( 0, compositeEnv, first ->cost + second->cost );1615 Alternative newAlt( 0, compositeEnv, first.cost + second.cost ); 1629 1616 Type* commonType = nullptr; 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());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(); 1633 1620 newAlt.expr = newExpr; 1634 1621 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) ); … … 1751 1738 findMinCost( minArgCost.begin(), minArgCost.end(), std::back_inserter( alternatives ) ); 1752 1739 } 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 } 1753 1748 } // namespace ResolvExpr 1754 1749 -
src/ResolvExpr/Resolver.cc
r62cd621 r7c782af 105 105 } 106 106 107 // used in resolveTypeof 108 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ) { 109 TypeEnvironment env; 110 return resolveInVoidContext( expr, indexer, env ); 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; 111 125 } 112 126 … … 130 144 } // namespace 131 145 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 132 241 void findVoidExpression( Expression *& untyped, const SymTab::Indexer &indexer ) { 133 242 resetTyVarRenaming(); 134 243 TypeEnvironment env; 135 Expression * newExpr = resolveInVoidContext( untyped, indexer, env );244 Expression * newExpr = resolveInVoidContext( untyped, indexer, env ); 136 245 finishExpr( newExpr, env, untyped->env ); 137 246 delete untyped; … … 140 249 141 250 void findSingleExpression( Expression *&untyped, const SymTab::Indexer &indexer ) { 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; 251 findKindExpression( untyped, indexer, "", standardAlternativeFilter ); 162 252 } 163 253 … … 170 260 171 261 namespace { 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 ) { 262 bool isIntegralType( const Alternative & alt ) { 263 Type * type = alt.expr->result; 209 264 if ( dynamic_cast< EnumInstType * >( type ) ) { 210 265 return true; … … 559 614 if( func_candidates.size() > 1 ) { SemanticError top( stmt->location, "Ambiguous function in call to waitfor" ); top.append( errors ); throw top; } 560 615 if( args_candidates.size() > 1 ) { SemanticError top( stmt->location, "Ambiguous arguments in call to waitfor" ); top.append( errors ); throw top; } 561 616 // TODO: need to use findDeletedExpr to ensure no deleted identifiers are used. 562 617 563 618 // Swap the results from the alternative with the unresolved values. … … 592 647 } 593 648 594 bool isStructOrUnion( Type *t ) {595 t =t->stripReferences();649 bool isStructOrUnion( const Alternative & alt ) { 650 Type * t = alt.expr->result->stripReferences(); 596 651 return dynamic_cast< StructInstType * >( t ) || dynamic_cast< UnionInstType * >( t ); 597 652 } -
src/ResolvExpr/Unify.cc
r62cd621 r7c782af 563 563 flatten( dcl->get_type(), back_inserter( types ) ); 564 564 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 565 569 dst.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::C, nullptr, t, nullptr ) ); 566 570 } … … 580 584 581 585 // sizes don't have to match if ttypes are involved; need to be more precise wrt where the ttype is to prevent errors 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 ) ) {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 ) ) { 585 589 586 590 // the original types must be used in mark assertions, since pointer comparisons are used … … 599 603 // check that other type is compatible and named the same 600 604 RefType *otherStruct = dynamic_cast< RefType* >( other ); 601 result = otherStruct && inst-> get_name() == otherStruct->get_name();605 result = otherStruct && inst->name == otherStruct->name; 602 606 } 603 607 … … 608 612 if ( ! result ) return; 609 613 // Check that parameters of types unify, if any 610 std::list< Expression* > params = inst-> get_parameters();611 std::list< Expression* > otherParams = ((RefType*)other)-> get_parameters();614 std::list< Expression* > params = inst->parameters; 615 std::list< Expression* > otherParams = ((RefType*)other)->parameters; 612 616 613 617 std::list< Expression* >::const_iterator it = params.begin(), jt = otherParams.begin(); -
src/SymTab/Autogen.cc
r62cd621 r7c782af 377 377 paramType->attributes.clear(); 378 378 // add a parameter corresponding to this field 379 memCtorType->parameters.push_back( new ObjectDecl( field->name, Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType, nullptr ) ); 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 ); 380 382 FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting ); 381 383 makeFieldCtorBody( aggregateDecl->members.begin(), aggregateDecl->members.end(), ctor ); -
src/SymTab/FixFunction.cc
r62cd621 r7c782af 36 36 } 37 37 38 // xxx - this passes on void[], e.g. 39 // void foo(void [10]); 40 // does not cause an error 41 38 42 Type * FixFunction::postmutate(ArrayType *arrayType) { 39 43 // need to recursively mutate the base type in order for multi-dimensional arrays to work. … … 62 66 void FixFunction::premutate(ZeroType *) { visit_children = false; } 63 67 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 } 64 74 } // namespace SymTab 65 75 -
src/SymTab/FixFunction.h
r62cd621 r7c782af 47 47 bool isVoid; 48 48 }; 49 50 bool fixFunction( DeclarationWithType *& ); 49 51 } // namespace SymTab 50 52 -
src/SymTab/Indexer.cc
r62cd621 r7c782af 286 286 } 287 287 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;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; 291 291 292 292 IdTable::const_iterator decls = tables->idTable.find( id ); … … 294 294 const MangleTable &mangleTable = decls->second; 295 295 MangleTable::const_iterator decl = mangleTable.find( mangleName ); 296 if ( decl != mangleTable.end() ) return decl->second.id;296 if ( decl != mangleTable.end() ) return &decl->second; 297 297 } 298 298 299 299 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 )); 300 304 } 301 305 … … 373 377 } 374 378 375 bool addedIdConflicts( DeclarationWithType *existing, DeclarationWithType *added) {379 bool addedIdConflicts( Indexer::IdData & existing, DeclarationWithType *added, BaseSyntaxNode * deleteStmt, Indexer::ConflictFunction handleConflicts ) { 376 380 // if we're giving the same name mangling to things of different types then there is something wrong 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() ) ) {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() ) ) { 381 385 // new definition shadows the autogenerated one, even at the same scope 382 386 return false; 383 } else if ( LinkageSpec::isMangled( added->get_linkage() ) || ResolvExpr::typesCompatible( added->get_type(), existing->get_type(), Indexer() ) ) { 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 384 396 // typesCompatible doesn't really do the right thing here. When checking compatibility of function types, 385 397 // we should ignore outermost pointer qualifiers, except _Atomic? 386 FunctionDecl * newentry = dynamic_cast< FunctionDecl* >( added );387 FunctionDecl * oldentry = dynamic_cast< FunctionDecl* >( existing);398 FunctionDecl * newentry = dynamic_cast< FunctionDecl * >( added ); 399 FunctionDecl * oldentry = dynamic_cast< FunctionDecl * >( existing.id ); 388 400 if ( newentry && oldentry ) { 389 401 if ( newentry->get_statements() && oldentry->get_statements() ) { 390 throw SemanticError( added, "duplicate function definition for " );402 return handleConflicts( existing, "duplicate function definition for " ); 391 403 } // if 392 404 } else { … … 395 407 // xxx - perhaps it's actually if either is intrinsic then this is okay? 396 408 // might also need to be same storage class? 397 ObjectDecl * newobj = dynamic_cast< ObjectDecl* >( added );398 ObjectDecl * oldobj = dynamic_cast< ObjectDecl* >( existing);409 ObjectDecl * newobj = dynamic_cast< ObjectDecl * >( added ); 410 ObjectDecl * oldobj = dynamic_cast< ObjectDecl * >( existing.id ); 399 411 if ( ! newobj->get_storageClasses().is_extern && ! oldobj->get_storageClasses().is_extern ) { 400 throw SemanticError( added, "duplicate object definition for " );412 return handleConflicts( existing, "duplicate object definition for " ); 401 413 } // if 402 414 } // if 403 415 } else { 404 throw SemanticError( added, "duplicate definition for " );416 return handleConflicts( existing, "duplicate definition for " ); 405 417 } // if 406 418 … … 408 420 } 409 421 410 void Indexer::addId( DeclarationWithType *decl, Expression * baseExpr) {422 void Indexer::addId( DeclarationWithType *decl, ConflictFunction handleConflicts, Expression * baseExpr, BaseSyntaxNode * deleteStmt ) { 411 423 if ( decl->name == "" ) return; 412 424 debugPrint( "Adding Id " << decl->name << std::endl ); … … 434 446 } 435 447 } else { 436 // Check that a Cforall declaration doesn't over loadany C declaration448 // Check that a Cforall declaration doesn't override any C declaration 437 449 if ( hasCompatibleCDecl( name, mangleName, scope ) ) { 438 450 throw SemanticError( decl, "Cforall declaration hides C function " ); … … 441 453 442 454 // Skip repeat declarations of the same identifier 443 DeclarationWithType *existing = lookupIdAtScope( name, mangleName, scope );444 if ( existing && addedIdConflicts( existing, decl) ) return;455 IdData * existing = lookupIdAtScope( name, mangleName, scope ); 456 if ( existing && existing->id && addedIdConflicts( *existing, decl, deleteStmt, handleConflicts ) ) return; 445 457 446 458 // add to indexer 447 tables->idTable[ name ][ mangleName ] = { decl, baseExpr };459 tables->idTable[ name ][ mangleName ] = { decl, baseExpr, deleteStmt }; 448 460 ++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 ); 449 471 } 450 472 … … 573 595 } 574 596 575 void Indexer::addMembers( AggregateDecl * aggr, Expression * expr ) {597 void Indexer::addMembers( AggregateDecl * aggr, Expression * expr, ConflictFunction handleConflicts ) { 576 598 for ( Declaration * decl : aggr->members ) { 577 599 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) { 578 addId( dwt, expr );600 addId( dwt, handleConflicts, expr ); 579 601 if ( dwt->name == "" ) { 580 602 Type * t = dwt->get_type()->stripReferences(); … … 582 604 Expression * base = expr->clone(); 583 605 ResolvExpr::referenceToRvalueConversion( base ); 584 addMembers( t->getAggr(), new MemberExpr( dwt, base ) );606 addMembers( t->getAggr(), new MemberExpr( dwt, base ), handleConflicts ); 585 607 } 586 608 } … … 589 611 } 590 612 591 void Indexer::addWith( std::list< Expression * > & withExprs ) {613 void Indexer::addWith( std::list< Expression * > & withExprs, BaseSyntaxNode * withStmt ) { 592 614 for ( Expression * expr : withExprs ) { 593 615 if ( expr->result ) { … … 595 617 assertf( aggr, "WithStmt expr has non-aggregate type: %s", toString( expr->result ).c_str() ); 596 618 597 addMembers( aggr, expr ); 619 addMembers( aggr, expr, [withStmt](IdData & existing, const std::string &) { 620 // on conflict, delete the identifier 621 existing.deleteStmt = withStmt; 622 return true; 623 }); 598 624 } 599 625 } … … 654 680 655 681 void Indexer::print( std::ostream &os, int indent ) const { 656 682 using std::cerr; 657 683 658 684 if ( tables ) { … … 680 706 681 707 Expression * Indexer::IdData::combine() const { 708 Expression * ret = nullptr; 682 709 if ( baseExpr ) { 683 710 Expression * base = baseExpr->clone(); 684 711 ResolvExpr::referenceToRvalueConversion( base ); 685 Expression *ret = new MemberExpr( id, base );712 ret = new MemberExpr( id, base ); 686 713 // xxx - this introduces hidden environments, for now remove them. 687 714 // std::swap( base->env, ret->env ); 688 715 delete base->env; 689 716 base->env = nullptr; 690 return ret; 691 } else { 692 return new VariableExpr( id ); 693 } 717 } else { 718 ret = new VariableExpr( id ); 719 } 720 if ( deleteStmt ) ret = new DeletedExpr( ret, deleteStmt ); 721 return ret; 694 722 } 695 723 } // namespace SymTab -
src/SymTab/Indexer.h
r62cd621 r7c782af 19 19 #include <list> // for list 20 20 #include <string> // for string 21 #include <functional> // for function 21 22 22 23 #include "SynTree/Visitor.h" // for Visitor … … 40 41 41 42 struct IdData { 42 DeclarationWithType * id; 43 Expression * baseExpr; // WithExpr 43 DeclarationWithType * id = nullptr; 44 Expression * baseExpr = nullptr; // WithExpr 45 46 /// non-null if this declaration is deleted 47 BaseSyntaxNode * deleteStmt = nullptr; 44 48 45 49 Expression * combine() const; … … 62 66 63 67 /// looks up a specific mangled ID at the given scope 64 DeclarationWithType *lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) const; 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; 65 70 /// returns true if there exists a declaration with C linkage and the given name with a different mangled name 66 71 bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const; … … 74 79 TraitDecl *lookupTraitAtScope( const std::string &id, unsigned long scope ) const; 75 80 76 void addId( DeclarationWithType *decl, Expression * baseExpr = nullptr ); 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 77 86 void addType( NamedTypeDecl *decl ); 78 87 void addStruct( const std::string &id ); … … 84 93 85 94 /// adds all of the IDs from WithStmt exprs 86 void addWith( std::list< Expression * > & withExprs );95 void addWith( std::list< Expression * > & withExprs, BaseSyntaxNode * withStmt ); 87 96 88 97 /// adds all of the members of the Aggregate (addWith helper) 89 void addMembers( AggregateDecl * aggr, Expression * expr );98 void addMembers( AggregateDecl * aggr, Expression * expr, ConflictFunction ); 90 99 91 100 /// convenience function for adding a list of Ids to the indexer … … 117 126 /// Ensures that tables variable is writable (i.e. allocated, uniquely owned by this Indexer, and at the current scope) 118 127 void makeWritable(); 128 129 /// common code for addId, addDeletedId, etc. 130 void addId( DeclarationWithType * decl, ConflictFunction, Expression * baseExpr = nullptr, BaseSyntaxNode * deleteStmt = nullptr ); 119 131 }; 120 132 } // namespace SymTab -
src/SymTab/Mangler.cc
r62cd621 r7c782af 37 37 struct Mangler : public WithShortCircuiting, public WithVisitorRef<Mangler> { 38 38 Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams ); 39 Mangler( const Mangler & ) ;39 Mangler( const Mangler & ) = delete; 40 40 41 41 void previsit( BaseSyntaxNode * ) { visit_children = false; } -
src/SymTab/Validate.cc
r62cd621 r7c782af 351 351 namespace { 352 352 template< typename DWTList > 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 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 } 380 371 } 381 372 } … … 383 374 void EnumAndPointerDecay::previsit( FunctionType *func ) { 384 375 // Fix up parameters and return types 385 fixFunctionList( func-> get_parameters(), func );386 fixFunctionList( func-> get_returnVals(), func );376 fixFunctionList( func->parameters, func->isVarArgs, func ); 377 fixFunctionList( func->returnVals, false, func ); 387 378 } 388 379 … … 626 617 // apply FixFunction to every assertion to check for invalid void type 627 618 for ( DeclarationWithType *& assertion : type->assertions ) { 628 PassVisitor<FixFunction> fixer; 629 assertion = assertion->acceptMutator( fixer ); 630 if ( fixer.pass.isVoid ) { 619 bool isVoid = fixFunction( assertion ); 620 if ( isVoid ) { 631 621 throw SemanticError( node, "invalid type void in assertion of function " ); 632 622 } // if -
src/SynTree/Attribute.cc
r62cd621 r7c782af 15 15 16 16 #include <ostream> // for operator<<, ostream, basic_ostream, endl 17 #include <set> 17 18 18 19 #include "Attribute.h" … … 21 22 22 23 Attribute::Attribute( const Attribute &other ) : name( other.name ) { 23 24 cloneAll( other.parameters, parameters ); 24 25 } 25 26 26 27 Attribute::~Attribute() { 27 deleteAll( parameters ); 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; 28 50 } 29 51 30 52 void Attribute::print( std::ostream &os, Indenter indent ) const { 31 32 53 using std::endl; 54 using std::string; 33 55 34 35 36 37 38 39 40 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 } 41 63 } 42 64 -
src/SynTree/Attribute.h
r62cd621 r7c782af 43 43 bool empty() const { return name == ""; } 44 44 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 45 50 Attribute * clone() const override { return new Attribute( *this ); } 46 51 virtual void accept( Visitor & v ) override { v.visit( this ); } -
src/SynTree/Expression.cc
r62cd621 r7c782af 710 710 } 711 711 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 712 729 // Local Variables: // 713 730 // tab-width: 4 // -
src/SynTree/Expression.h
r62cd621 r7c782af 822 822 }; 823 823 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 824 840 // Local Variables: // 825 841 // tab-width: 4 // -
src/SynTree/Mutator.h
r62cd621 r7c782af 55 55 virtual Statement * mutate( ImplicitCtorDtorStmt * impCtorDtorStmt ); 56 56 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 ); 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; 91 92 92 93 virtual Type * mutate( VoidType * basicType ); -
src/SynTree/Statement.cc
r62cd621 r7c782af 468 468 void WithStmt::print( std::ostream & os, Indenter indent ) const { 469 469 os << "With statement" << endl; 470 os << indent << "... with expressions: " << endl; 471 printAll( exprs, os, indent+1 ); 470 472 os << indent << "... with statement:" << endl << indent+1; 471 473 stmt->print( os, indent+1 ); -
src/SynTree/SynTree.h
r62cd621 r7c782af 97 97 class UntypedInitExpr; 98 98 class InitExpr; 99 class DeletedExpr; 99 100 100 101 class Type; -
src/SynTree/Visitor.h
r62cd621 r7c782af 91 91 virtual void visit( UntypedInitExpr * initExpr ); 92 92 virtual void visit( InitExpr * initExpr ); 93 virtual void visit( DeletedExpr * delExpr ) = 0; 93 94 94 95 virtual void visit( VoidType * basicType ); -
src/Tuples/Explode.h
r62cd621 r7c782af 43 43 /// Append alternative to an OutputIterator of Alternatives 44 44 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, 46 46 const ResolvExpr::Cost& cost, const ResolvExpr::Cost& cvtCost ) { 47 47 *out++ = ResolvExpr::Alternative{ expr, env, cost, cvtCost }; … … 49 49 50 50 /// 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, 52 52 const ResolvExpr::TypeEnvironment&, const ResolvExpr::Cost&, const ResolvExpr::Cost& ) { 53 53 ea.exprs.emplace_back( expr ); … … 57 57 /// helper function used by explode 58 58 template< typename Output > 59 void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt, 59 void explodeUnique( Expression * expr, const ResolvExpr::Alternative & alt, 60 60 const SymTab::Indexer & indexer, Output&& out, bool isTupleAssign ) { 61 61 if ( isTupleAssign ) { … … 63 63 if ( CastExpr * castExpr = isReferenceCast( expr ) ) { 64 64 ResolvExpr::AltList alts; 65 explodeUnique( 65 explodeUnique( 66 66 castExpr->get_arg(), alt, indexer, back_inserter( alts ), isTupleAssign ); 67 67 for ( ResolvExpr::Alternative & alt : alts ) { 68 68 // 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() ), 70 70 alt.env, alt.cost, alt.cvtCost ); 71 71 } … … 108 108 /// expands a tuple-valued alternative into multiple alternatives, each with a non-tuple-type 109 109 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, 111 111 Output&& out, bool isTupleAssign = false ) { 112 112 explodeUnique( alt.expr, alt, indexer, std::forward<Output>(out), isTupleAssign ); … … 115 115 // explode list of alternatives 116 116 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, 118 118 Output&& out, bool isTupleAssign = false ) { 119 119 for ( ; altBegin != altEnd; ++altBegin ) { … … 123 123 124 124 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, 126 126 bool isTupleAssign = false ) { 127 127 explode( alts.begin(), alts.end(), indexer, std::forward<Output>(out), isTupleAssign ); -
src/libcfa/assert.c
r62cd621 r7c782af 22 22 extern const char * __progname; // global name of running executable (argv[0]) 23 23 24 #define CFA_ASSERT_FMT "Cforall Assertion error from program \"%s\" in \"%s\" at line %d in file \"%s\""24 #define CFA_ASSERT_FMT "Cforall Assertion error \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\"" 25 25 26 26 // called by macro assert in assert.h 27 27 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", __progname, function, line, file );28 __cfaabi_dbg_bits_print_safe( CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file ); 29 29 abort(); 30 30 } … … 33 33 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) { 34 34 __cfaabi_dbg_bits_acquire(); 35 __cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", __progname, function, line, file );35 __cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file ); 36 36 37 37 va_list args; -
src/tests/.expect/attributes.x64.txt
r62cd621 r7c782af 63 63 static inline void ___destructor__F_R4sFdl_autogen___1(struct Fdl *___dst__R4sFdl_1); 64 64 static 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, signed int __f1__i_1);66 static inline void ___constructor__F_R4sFdlii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1,signed int __f2__i_1);67 static 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);68 static 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);69 static 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);70 static 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);71 static 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);72 static 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);73 static 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);74 static 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);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); 75 75 static inline void ___constructor__F_R4sFdl_autogen___1(struct Fdl *___dst__R4sFdl_1){ 76 76 ((void)((*___dst__R4sFdl_1).__f1__i_1) /* ?{} */); … … 124 124 return ___ret__4sFdl_1; 125 125 } 126 static inline void ___constructor__F_R4sFdli_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1){126 static inline void ___constructor__F_R4sFdli_autogen___1(struct Fdl *___dst__R4sFdl_1, __attribute__ ((unused)) signed int __f1__i_1){ 127 127 ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */); 128 128 ((void)((*___dst__R4sFdl_1).__f2__i_1) /* ?{} */); … … 136 136 ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */); 137 137 } 138 static inline void ___constructor__F_R4sFdlii_autogen___1(struct Fdl *___dst__R4sFdl_1, signed int __f1__i_1,signed int __f2__i_1){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){ 139 139 ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */); 140 140 ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */); … … 148 148 ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */); 149 149 } 150 static 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){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){ 151 151 ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */); 152 152 ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */); … … 160 160 ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */); 161 161 } 162 static 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){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){ 163 163 ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */); 164 164 ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */); … … 172 172 ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */); 173 173 } 174 static 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 } 186 static 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){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){ 187 187 ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */); 188 188 ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */); … … 196 196 ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */); 197 197 } 198 static 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){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){ 199 199 ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */); 200 200 ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */); … … 208 208 ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */); 209 209 } 210 static 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){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){ 211 211 ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */); 212 212 ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */); … … 220 220 ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */); 221 221 } 222 static 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){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){ 223 223 ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */); 224 224 ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */); … … 232 232 ((void)((*___dst__R4sFdl_1).__f9__Pi_1) /* ?{} */); 233 233 } 234 static 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){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){ 235 235 ((void)((*___dst__R4sFdl_1).__f1__i_1=__f1__i_1) /* ?{} */); 236 236 ((void)((*___dst__R4sFdl_1).__f2__i_1=__f2__i_1) /* ?{} */); … … 371 371 static inline void ___destructor__F_R4sVad_autogen___1(struct Vad *___dst__R4sVad_1); 372 372 static 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, signed int __anonymous_object36);374 static inline void ___constructor__F_R4sVadiPi_autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object37,signed int *__anonymous_object38);375 static 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)]);376 static 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)());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)()); 377 377 static inline void ___constructor__F_R4sVad_autogen___1(struct Vad *___dst__R4sVad_1){ 378 378 ((void)((*___dst__R4sVad_1).__anonymous_object32) /* ?{} */); … … 430 430 return ___ret__4sVad_1; 431 431 } 432 static inline void ___constructor__F_R4sVadi_autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object46){432 static inline void ___constructor__F_R4sVadi_autogen___1(struct Vad *___dst__R4sVad_1, __attribute__ ((unused)) signed int __anonymous_object46){ 433 433 ((void)((*___dst__R4sVad_1).__anonymous_object32=__anonymous_object46) /* ?{} */); 434 434 ((void)((*___dst__R4sVad_1).__anonymous_object33) /* ?{} */); … … 443 443 ((void)((*___dst__R4sVad_1).__anonymous_object35) /* ?{} */); 444 444 } 445 static inline void ___constructor__F_R4sVadiPi_autogen___1(struct Vad *___dst__R4sVad_1, signed int __anonymous_object47,signed int *__anonymous_object48){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){ 446 446 ((void)((*___dst__R4sVad_1).__anonymous_object32=__anonymous_object47) /* ?{} */); 447 447 ((void)((*___dst__R4sVad_1).__anonymous_object33=__anonymous_object48) /* ?{} */); … … 456 456 ((void)((*___dst__R4sVad_1).__anonymous_object35) /* ?{} */); 457 457 } 458 static 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)]){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)]){ 459 459 ((void)((*___dst__R4sVad_1).__anonymous_object32=__anonymous_object49) /* ?{} */); 460 460 ((void)((*___dst__R4sVad_1).__anonymous_object33=__anonymous_object50) /* ?{} */); … … 469 469 ((void)((*___dst__R4sVad_1).__anonymous_object35) /* ?{} */); 470 470 } 471 static 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)()){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)()){ 472 472 ((void)((*___dst__R4sVad_1).__anonymous_object32=__anonymous_object52) /* ?{} */); 473 473 ((void)((*___dst__R4sVad_1).__anonymous_object33=__anonymous_object53) /* ?{} */); -
src/tests/tuple/tupleVariadic.c
r62cd621 r7c782af 95 95 } 96 96 97 forall(ttype T | { void foo(T); }) void bar(T x) {} 98 void foo(int) {} 99 97 100 int main() { 98 101 array * x0 = new(); … … 117 120 func(3, 2.0, 111, 4.145); 118 121 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 } 119 128 } 120 129
Note:
See TracChangeset
for help on using the changeset viewer.