Changeset 0f40912


Ignore:
Timestamp:
Apr 3, 2018, 1:58:10 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
593370c
Parents:
bd87b138
git-author:
Rob Schluntz <rschlunt@…> (04/03/18 11:14:58)
git-committer:
Rob Schluntz <rschlunt@…> (04/03/18 13:58:10)
Message:

Hoist _Static_assert declarations from struct/union bodies

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    rbd87b138 r0f40912  
    8989                void previsit( StructDecl * aggregateDecl );
    9090                void previsit( UnionDecl * aggregateDecl );
     91                void previsit( StaticAssertDecl * assertDecl );
    9192
    9293          private:
     
    296297        }
    297298
    298         bool isStructOrUnion( Declaration *decl ) {
    299                 return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl );
     299        bool shouldHoist( Declaration *decl ) {
     300                return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl ) || dynamic_cast< StaticAssertDecl * >( decl );
    300301        }
    301302
     
    310311                } // if
    311312                // Always remove the hoisted aggregate from the inner structure.
    312                 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, isStructOrUnion, false ); } );
     313                GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, shouldHoist, false ); } );
    313314        }
    314315
     
    328329                if ( inst->baseUnion ) {
    329330                        declsToAddBefore.push_front( inst->baseUnion );
     331                }
     332        }
     333
     334        void HoistStruct::previsit( StaticAssertDecl * assertDecl ) {
     335                if ( parentAggr ) {
     336                        declsToAddBefore.push_back( assertDecl );
    330337                }
    331338        }
Note: See TracChangeset for help on using the changeset viewer.