Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    ra16764a6 rbbf3fda  
    8989                void previsit( StructDecl * aggregateDecl );
    9090                void previsit( UnionDecl * aggregateDecl );
     91                void previsit( StaticAssertDecl * assertDecl );
    9192
    9293          private:
     
    147148                void previsit( ObjectDecl * object );
    148149                void previsit( FunctionDecl * func );
     150                void previsit( FunctionType * ftype );
    149151                void previsit( StructDecl * aggrDecl );
    150152                void previsit( UnionDecl * aggrDecl );
     
    296298        }
    297299
    298         bool isStructOrUnion( Declaration *decl ) {
    299                 return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl );
     300        bool shouldHoist( Declaration *decl ) {
     301                return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl ) || dynamic_cast< StaticAssertDecl * >( decl );
    300302        }
    301303
     
    310312                } // if
    311313                // Always remove the hoisted aggregate from the inner structure.
    312                 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, isStructOrUnion, false ); } );
     314                GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, shouldHoist, false ); } );
    313315        }
    314316
     
    328330                if ( inst->baseUnion ) {
    329331                        declsToAddBefore.push_front( inst->baseUnion );
     332                }
     333        }
     334
     335        void HoistStruct::previsit( StaticAssertDecl * assertDecl ) {
     336                if ( parentAggr ) {
     337                        declsToAddBefore.push_back( assertDecl );
    330338                }
    331339        }
     
    626634
    627635        void ForallPointerDecay::previsit( ObjectDecl *object ) {
    628                 forallFixer( object->type->forall, object );
    629                 if ( PointerType *pointer = dynamic_cast< PointerType * >( object->type ) ) {
    630                         forallFixer( pointer->base->forall, object );
    631                 } // if
     636                // ensure that operator names only apply to functions or function pointers
     637                if ( CodeGen::isOperator( object->name ) && ! dynamic_cast< FunctionType * >( object->type->stripDeclarator() ) ) {
     638                        SemanticError( object->location, toCString( "operator ", object->name.c_str(), " is not a function or function pointer." ) );
     639                }
    632640                object->fixUniqueId();
    633641        }
    634642
    635643        void ForallPointerDecay::previsit( FunctionDecl *func ) {
    636                 forallFixer( func->type->forall, func );
    637644                func->fixUniqueId();
     645        }
     646
     647        void ForallPointerDecay::previsit( FunctionType * ftype ) {
     648                forallFixer( ftype->forall, ftype );
    638649        }
    639650
Note: See TracChangeset for help on using the changeset viewer.