Changeset da0edec


Ignore:
Timestamp:
Jun 20, 2023, 4:14:32 PM (17 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
2de175ce
Parents:
9c4330d5 (diff), caf06aa (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

Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/GenericParameter.cpp

    r9c4330d5 rda0edec  
    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};
Note: See TracChangeset for help on using the changeset viewer.