Changeset c84dd61 for src/Validate


Ignore:
Timestamp:
Jun 21, 2023, 2:38:55 AM (16 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
92355883
Parents:
0b0a285 (diff), 2de175ce (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/Validate
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/Autogen.cpp

    r0b0a285 rc84dd61  
    321321void FuncGenerator::produceDecl( const ast::FunctionDecl * decl ) {
    322322        assert( nullptr != decl->stmts );
     323        assert( decl->type_params.size() == getGenericParams( type ).size() );
    323324
    324325        definitions.push_back( decl );
     
    356357                decl->init = nullptr;
    357358                splice( assertions, decl->assertions );
    358                 oldToNew.emplace( std::make_pair( old_param, decl ) );
     359                oldToNew.emplace( old_param, decl );
    359360                type_params.push_back( decl );
    360361        }
     
    522523        InitTweak::InitExpander_new srcParam( src );
    523524        // Assign to destination.
    524         ast::Expr * dstSelect = new ast::MemberExpr(
     525        ast::MemberExpr * dstSelect = new ast::MemberExpr(
    525526                location,
    526527                field,
     
    574575                }
    575576
    576                 ast::Expr * srcSelect = (srcParam) ? new ast::MemberExpr(
     577                ast::MemberExpr * srcSelect = (srcParam) ? new ast::MemberExpr(
    577578                        location, field, new ast::VariableExpr( location, srcParam )
    578579                ) : nullptr;
  • src/Validate/GenericParameter.cpp

    r0b0a285 rc84dd61  
    120120}
    121121
    122 struct ValidateGenericParamsCore : public ast::WithCodeLocation {
     122bool isSizedPolymorphic( const ast::AggregateDecl * decl ) {
     123        for ( const auto & param : decl->params ) {
     124                if ( param->sized ) return true;
     125        }
     126        return false;
     127}
     128
     129struct ValidateGenericParamsCore :
     130                public ast::WithCodeLocation, public ast::WithGuards {
     131        // Generic parameter filling and checks:
    123132        const ast::StructInstType * previsit( const ast::StructInstType * type ) {
    124133                assert( location );
     
    129138                assert( location );
    130139                return validateGeneric( *location, type );
     140        }
     141
     142        // Check parameter and bitfield combinations:
     143        bool insideSized = false;
     144        void previsit( const ast::StructDecl * decl ) {
     145                if ( isSizedPolymorphic( decl ) && !insideSized ) {
     146                        GuardValue( insideSized ) = true;
     147                }
     148        }
     149
     150        void previsit( const ast::UnionDecl * decl ) {
     151                if ( isSizedPolymorphic( decl ) && !insideSized ) {
     152                        GuardValue( insideSized ) = true;
     153                }
     154        }
     155
     156        void previsit( const ast::ObjectDecl * decl ) {
     157                if ( insideSized && decl->bitfieldWidth ) {
     158                        SemanticError( decl->location, decl,
     159                                "Cannot have bitfields inside a sized polymorphic structure." );
     160                }
    131161        }
    132162};
  • src/Validate/LinkReferenceToTypes.cpp

    r0b0a285 rc84dd61  
    8484                // Just linking in the node.
    8585                auto mut = ast::mutate( type );
    86                 mut->base = const_cast<ast::EnumDecl *>( decl );
     86                mut->base = decl;
    8787                type = mut;
    8888        }
     
    101101                // Just linking in the node.
    102102                auto mut = ast::mutate( type );
    103                 mut->base = const_cast<ast::StructDecl *>( decl );
     103                mut->base = decl;
    104104                type = mut;
    105105        }
     
    118118                // Just linking in the node.
    119119                auto mut = ast::mutate( type );
    120                 mut->base = const_cast<ast::UnionDecl *>( decl );
     120                mut->base = decl;
    121121                type = mut;
    122122        }
     
    141141
    142142        // Just linking in the node.
    143         mut->base = const_cast<ast::TraitDecl *>( decl );
     143        mut->base = decl;
    144144
    145145        // Need to carry over the 'sized' status of each decl in the instance.
     
    203203        }
    204204
    205         // The following section
    206 
    207205        ForwardEnumsType::iterator fwds = forwardEnums.find( decl->name );
    208206        if ( fwds != forwardEnums.end() ) {
Note: See TracChangeset for help on using the changeset viewer.