Changes in / [185cd94:b1c220a]
- Files:
-
- 5 edited
-
src/GenPoly/InstantiateGeneric.cpp (modified) (4 diffs)
-
src/ResolvExpr/Resolver.cpp (modified) (2 diffs)
-
tests/.expect/functions.arm64.txt (modified) (4 diffs)
-
tests/.expect/functions.x64.txt (modified) (4 diffs)
-
tests/.expect/functions.x86.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/InstantiateGeneric.cpp
r185cd94 rb1c220a 42 42 43 43 using type_vector = ast::vector< ast::TypeExpr >; 44 45 template<typename C, typename V>46 bool contains( C const & container, V const & value ) {47 return std::any_of( container.begin(), container.end(),48 [value]( auto& element ){ return element == value; } );49 }50 44 51 45 /// Abstracts type equality for a list of parameter types. … … 429 423 } 430 424 431 classGenericInstantiator final :425 struct GenericInstantiator final : 432 426 public ast::WithCodeLocation, 433 427 public ast::WithConstTypeSubstitution, … … 450 444 /// member from an instantiation. 451 445 int memberIndex = -1; 452 /// The polymorphic types we are currently instantiating.453 ast::vector<ast::Decl> instantiating;454 public:455 446 456 447 GenericInstantiator() : … … 606 597 ); 607 598 608 // Insert the declaration so it doesn't create it again,599 // Forward declare before recursion. (TODO: Only when needed, #199.) 609 600 insert( inst, typeSubs, newDecl ); 610 // ... but mark this declaration as one we are working on. 611 auto guard = makeFuncGuard( 612 [this, newDecl](){ instantiating.push_back( newDecl ); }, 613 [this](){ instantiating.pop_back(); } ); 601 if ( AggrDecl const * forwardDecl = ast::asForward( newDecl ) ) { 602 declsToAddBefore.push_back( forwardDecl ); 603 } 614 604 // Recursively instantiate members: 615 605 concDecl = strict_dynamic_cast<AggrDecl const *>( 616 606 newDecl->accept( *visitor ) ); 617 618 // Produce the declaration after its members are instantiated.607 // Must occur before declaration is added so 608 // that member instantiation appear first. 619 609 declsToAddBefore.push_back( concDecl ); 620 } else if ( contains( instantiating, concDecl ) ) {621 if ( AggrDecl const * forwardDecl = ast::asForward( concDecl ) ) {622 declsToAddBefore.push_back( forwardDecl );623 }624 610 } 625 611 return new ast::SueInstType<AggrDecl>( concDecl, inst->qualifiers ); -
src/ResolvExpr/Resolver.cpp
r185cd94 rb1c220a 703 703 } else { 704 704 if ( !objectDecl->isTypeFixed ) { 705 objectDecl = fixObjectType(objectDecl, context); 705 auto newDecl = fixObjectType(objectDecl, context); 706 auto mutDecl = mutate(newDecl); 706 707 707 708 // generate CtorInit wrapper when necessary. … … 709 710 // this object in visitor pass, thus disabling CtorInit codegen. 710 711 // this happens on aggregate members and function parameters. 711 if ( shouldGenCtorInit( objectDecl ) ) {712 if ( shouldGenCtorInit( mutDecl ) ) { 712 713 // constructed objects cannot be designated 713 if ( InitTweak::isDesignated( objectDecl->init ) 714 && !ast::Pass<ResolveDesignators>::read( 715 objectDecl->init.get(), context ) ) { 716 SemanticError( objectDecl, "Cannot include designations in the initializer for a managed Object.\n" 717 "If this is really what you want, initialize with @=." ); 714 if ( InitTweak::isDesignated( mutDecl->init ) ) { 715 ast::Pass<ResolveDesignators> res( context ); 716 maybe_accept( mutDecl->init.get(), res ); 717 if ( !res.core.result ) { 718 SemanticError( mutDecl, "Cannot include designations in the initializer for a managed Object.\n" 719 "If this is really what you want, initialize with @=." ); 720 } 718 721 } 719 722 // constructed objects should not have initializers nested too deeply 720 if ( !InitTweak::checkInitDepth( objectDecl ) ) SemanticError( objectDecl, "Managed object's initializer is too deep " ); 721 722 objectDecl = ast::mutate_field( objectDecl, &ast::ObjectDecl::init, 723 InitTweak::genCtorInit( objectDecl->location, objectDecl ) ); 723 if ( ! InitTweak::checkInitDepth( mutDecl ) ) SemanticError( mutDecl, "Managed object's initializer is too deep " ); 724 725 mutDecl->init = InitTweak::genCtorInit( mutDecl->location, mutDecl ); 724 726 } 727 728 objectDecl = mutDecl; 725 729 } 726 730 currentObject = ast::CurrentObject{ objectDecl->location, objectDecl->get_type() }; -
tests/.expect/functions.arm64.txt
r185cd94 rb1c220a 139 139 140 140 } 141 struct _conc__tuple2_0; 141 142 struct _conc__tuple2_0 { 142 143 signed int field_0; … … 181 182 182 183 } 184 struct _conc__tuple3_1; 183 185 struct _conc__tuple3_1 { 184 186 signed int field_0; … … 200 202 __attribute__ ((unused)) struct _conc__tuple3_1 _X9_retval_fT3iii_1 = { }; 201 203 } 204 struct _conc__tuple3_2; 202 205 struct _conc__tuple3_2 { 203 206 signed int field_0; … … 291 294 __attribute__ ((unused)) signed int *const _X10_retval_f3KPi_1; 292 295 } 296 struct _conc__tuple2_3; 293 297 struct _conc__tuple2_3 { 294 298 signed int *field_0; -
tests/.expect/functions.x64.txt
r185cd94 rb1c220a 139 139 140 140 } 141 struct _conc__tuple2_0; 141 142 struct _conc__tuple2_0 { 142 143 signed int field_0; … … 181 182 182 183 } 184 struct _conc__tuple3_1; 183 185 struct _conc__tuple3_1 { 184 186 signed int field_0; … … 200 202 __attribute__ ((unused)) struct _conc__tuple3_1 _X9_retval_fT3iii_1 = { }; 201 203 } 204 struct _conc__tuple3_2; 202 205 struct _conc__tuple3_2 { 203 206 signed int field_0; … … 291 294 __attribute__ ((unused)) signed int *const _X10_retval_f3KPi_1; 292 295 } 296 struct _conc__tuple2_3; 293 297 struct _conc__tuple2_3 { 294 298 signed int *field_0; -
tests/.expect/functions.x86.txt
r185cd94 rb1c220a 139 139 140 140 } 141 struct _conc__tuple2_0; 141 142 struct _conc__tuple2_0 { 142 143 signed int field_0; … … 181 182 182 183 } 184 struct _conc__tuple3_1; 183 185 struct _conc__tuple3_1 { 184 186 signed int field_0; … … 200 202 __attribute__ ((unused)) struct _conc__tuple3_1 _X9_retval_fT3iii_1 = { }; 201 203 } 204 struct _conc__tuple3_2; 202 205 struct _conc__tuple3_2 { 203 206 signed int field_0; … … 291 294 __attribute__ ((unused)) signed int *const _X10_retval_f3KPi_1; 292 295 } 296 struct _conc__tuple2_3; 293 297 struct _conc__tuple2_3 { 294 298 signed int *field_0;
Note:
See TracChangeset
for help on using the changeset viewer.