Changeset 9cdfb4d0 for src/SymTab


Ignore:
Timestamp:
Jan 22, 2018, 3:09:01 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
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, resolv-new, stuck-waitfor-destruct, with_gc
Children:
e23d20b
Parents:
326cd2b (diff), 4bf3b2b (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/SymTab
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    r326cd2b r9cdfb4d0  
    572572        }
    573573
     574        void Indexer::addMembers( AggregateDecl * aggr, Expression * expr ) {
     575                for ( Declaration * decl : aggr->members ) {
     576                        if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
     577                                addId( dwt, expr );
     578                                if ( dwt->name == "" ) {
     579                                        Type * t = dwt->get_type()->stripReferences();
     580                                        if ( dynamic_cast< StructInstType * >( t ) || dynamic_cast< UnionInstType * >( t ) ) {
     581                                                Expression * base = expr->clone();
     582                                                ResolvExpr::referenceToRvalueConversion( base );
     583                                                addMembers( t->getAggr(), new MemberExpr( dwt, base ) );
     584                                        }
     585                                }
     586                        }
     587                }
     588        }
     589
    574590        void Indexer::addWith( WithStmt * stmt ) {
    575591                for ( Expression * expr : stmt->exprs ) {
     
    578594                                assertf( aggr, "WithStmt expr has non-aggregate type: %s", toString( expr->result ).c_str() );
    579595
    580                                 for ( Declaration * decl : aggr->members ) {
    581                                         if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
    582                                                 addId( dwt, expr );
    583                                         }
    584                                 }
     596                                addMembers( aggr, expr );
    585597                        }
    586598                }
  • src/SymTab/Indexer.h

    r326cd2b r9cdfb4d0  
    8686                void addWith( WithStmt * );
    8787
     88                /// adds all of the members of the Aggregate (addWith helper)
     89                void addMembers( AggregateDecl * aggr, Expression * expr );
     90
    8891                /// convenience function for adding a list of Ids to the indexer
    8992                void addIds( const std::list< DeclarationWithType * > & decls );
  • src/SymTab/Validate.cc

    r326cd2b r9cdfb4d0  
    9494                template< typename AggDecl > void handleAggregate( AggDecl *aggregateDecl );
    9595
    96                 bool inStruct = false;
     96                AggregateDecl * parentAggr = nullptr;
    9797        };
    9898
     
    303303        template< typename AggDecl >
    304304        void HoistStruct::handleAggregate( AggDecl *aggregateDecl ) {
    305                 if ( inStruct ) {
     305                if ( parentAggr ) {
    306306                        // Add elements in stack order corresponding to nesting structure.
    307307                        declsToAddBefore.push_front( aggregateDecl );
    308308                } else {
    309                         GuardValue( inStruct );
    310                         inStruct = true;
     309                        GuardValue( parentAggr );
     310                        parentAggr = aggregateDecl;
    311311                } // if
    312312                // Always remove the hoisted aggregate from the inner structure.
     
    754754                                throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );
    755755                        }
    756                         // cannot redefine VLA typedefs
     756                        // Cannot redefine VLA typedefs. Note: this is slightly incorrect, because our notion of VLAs
     757                        // at this point in the translator is imprecise. In particular, this will disallow redefining typedefs
     758                        // with arrays whose dimension is an enumerator or a cast of a constant/enumerator. The effort required
     759                        // to fix this corner case likely outweighs the utility of allowing it.
    757760                        if ( isVariableLength( t1 ) || isVariableLength( t2 ) ) {
    758761                                throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );
Note: See TracChangeset for help on using the changeset viewer.