Changeset 1cdfa82 for src/SymTab


Ignore:
Timestamp:
Apr 25, 2018, 4:55:53 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
42107b4
Parents:
2efe4b8 (diff), 9d5fb67 (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 remote-tracking branch 'origin/master' into with_gc

Location:
src/SymTab
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    r2efe4b8 r1cdfa82  
    501501
    502502        bool addedDeclConflicts( AggregateDecl *existing, AggregateDecl *added ) {
    503                 if ( existing->get_members().empty() ) {
     503                if ( ! existing->body ) {
    504504                        return false;
    505                 } else if ( ! added->get_members().empty() ) {
     505                } else if ( added->body ) {
    506506                        SemanticError( added, "redeclaration of " );
    507507                } // if
  • src/SymTab/Validate.cc

    r2efe4b8 r1cdfa82  
    9090                void previsit( StructDecl * aggregateDecl );
    9191                void previsit( UnionDecl * aggregateDecl );
     92                void previsit( StaticAssertDecl * assertDecl );
    9293
    9394          private:
     
    148149                void previsit( ObjectDecl * object );
    149150                void previsit( FunctionDecl * func );
     151                void previsit( FunctionType * ftype );
    150152                void previsit( StructDecl * aggrDecl );
    151153                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 ); } );
     314                GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, shouldHoist, false ); } );
    313315        }
    314316
    315317        void HoistStruct::previsit( EnumInstType * inst ) {
    316                 if ( inst->baseEnum ) {
     318                if ( inst->baseEnum && inst->baseEnum->body ) {
    317319                        declsToAddBefore.push_front( inst->baseEnum );
    318320                }
     
    320322
    321323        void HoistStruct::previsit( StructInstType * inst ) {
    322                 if ( inst->baseStruct ) {
     324                if ( inst->baseStruct && inst->baseStruct->body ) {
    323325                        declsToAddBefore.push_front( inst->baseStruct );
    324326                }
     
    326328
    327329        void HoistStruct::previsit( UnionInstType * inst ) {
    328                 if ( inst->baseUnion ) {
     330                if ( inst->baseUnion && inst->baseUnion->body ) {
    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        }
     
    623631
    624632        void ForallPointerDecay::previsit( ObjectDecl *object ) {
    625                 forallFixer( object->type->forall, object );
    626                 if ( PointerType *pointer = dynamic_cast< PointerType * >( object->type ) ) {
    627                         forallFixer( pointer->base->forall, object );
    628                 } // if
     633                // ensure that operator names only apply to functions or function pointers
     634                if ( CodeGen::isOperator( object->name ) && ! dynamic_cast< FunctionType * >( object->type->stripDeclarator() ) ) {
     635                        SemanticError( object->location, toCString( "operator ", object->name.c_str(), " is not a function or function pointer." ) );
     636                }
    629637                object->fixUniqueId();
    630638        }
    631639
    632640        void ForallPointerDecay::previsit( FunctionDecl *func ) {
    633                 forallFixer( func->type->forall, func );
    634641                func->fixUniqueId();
     642        }
     643
     644        void ForallPointerDecay::previsit( FunctionType * ftype ) {
     645                forallFixer( ftype->forall, ftype );
    635646        }
    636647
     
    681692                                new_static_root<BasicType>( Type::Qualifiers(), BasicType::LongUnsignedInt );
    682693                }
    683                 filter( translationUnit, isTypedef );
     694                filter( translationUnit, isTypedef, true );
    684695        }
    685696
     
    818829                        } // if
    819830                        return false;
    820                 } );
     831                }, true);
    821832                return compoundStmt;
    822833        }
     
    826837        template<typename AggDecl>
    827838        AggDecl *EliminateTypedef::handleAggregate( AggDecl * aggDecl ) {
    828                 filter( aggDecl->members, isTypedef );
     839                filter( aggDecl->members, isTypedef, true );
    829840                return aggDecl;
    830841        }
Note: See TracChangeset for help on using the changeset viewer.