Ignore:
Timestamp:
Jul 20, 2015, 2:29:52 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
18997b9
Parents:
2794fff (diff), 994ec2c (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' into ctor

Conflicts:

src/Parser/ParseNode.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    r2794fff r893256d  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Jul 14 12:27:54 2015
    13 // Update Count     : 186
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jul 16 16:10:02 2015
     13// Update Count     : 189
    1414//
    1515
     
    6060        class HoistStruct : public Visitor {
    6161          public:
     62                /// Flattens nested struct types
    6263                static void hoistStruct( std::list< Declaration * > &translationUnit );
    6364 
     
    8485        };
    8586
     87        /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers
    8688        class Pass1 : public Visitor {
    8789                typedef Visitor Parent;
     
    8991                virtual void visit( FunctionType *func );
    9092        };
    91  
     93
     94        /// Associates forward declarations of aggregates with their definitions
    9295        class Pass2 : public Indexer {
    9396                typedef Indexer Parent;
     
    110113        };
    111114
     115        /// Replaces array and function types in forall lists by appropriate pointer type
    112116        class Pass3 : public Indexer {
    113117                typedef Indexer Parent;
     
    123127        class AddStructAssignment : public Visitor {
    124128          public:
     129                /// Generates assignment operators for aggregate types as required
    125130                static void addStructAssignment( std::list< Declaration * > &translationUnit );
    126131
     
    157162        class EliminateTypedef : public Mutator {
    158163          public:
    159           EliminateTypedef() : scopeLevel( 0 ) {}
     164                EliminateTypedef() : scopeLevel( 0 ) {}
    160165                static void eliminateTypedef( std::list< Declaration * > &translationUnit );
    161166          private:
     
    163168                virtual TypeDecl *mutate( TypeDecl *typeDecl );
    164169                virtual DeclarationWithType *mutate( FunctionDecl *funcDecl );
    165                 virtual ObjectDecl *mutate( ObjectDecl *objDecl );
     170                virtual DeclarationWithType *mutate( ObjectDecl *objDecl );
    166171                virtual CompoundStmt *mutate( CompoundStmt *compoundStmt );
    167172                virtual Type *mutate( TypeInstType *aggregateUseType );
     
    444449        }
    445450
     451        /// Fix up assertions
    446452        void forallFixer( Type *func ) {
    447                 // Fix up assertions
    448453                for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {
    449454                        std::list< DeclarationWithType * > toBeDone, nextRound;
     
    607612
    608613                // need to remove the prototypes, since this may be nested in a routine
    609                 for (int start = 0, end = assigns.size()/2; start < end; start++) {
     614                for ( int start = 0, end = assigns.size() / 2; start < end; start++ ) {
    610615                        delete assigns.front();
    611616                        assigns.pop_front();
    612                 }
     617                } // for
    613618
    614619                declsToAdd.insert( declsToAdd.begin(), assigns.begin(), assigns.end() );
     
    817822                        Type *ret = def->second.first->get_base()->clone();
    818823                        ret->get_qualifiers() += typeInst->get_qualifiers();
     824                        // place instance parameters on the typedef'd type
     825                        if ( ! typeInst->get_parameters().empty() ) {
     826                                ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret);
     827                                if ( ! rtt ) {
     828                                        throw SemanticError("cannot apply type parameters to base type of " + typeInst->get_name());
     829                                }
     830                                rtt->get_parameters().clear();
     831                                cloneAll(typeInst->get_parameters(), rtt->get_parameters());
     832                        } // if
    819833                        delete typeInst;
    820834                        return ret;
     
    870884        }
    871885
    872         ObjectDecl *EliminateTypedef::mutate( ObjectDecl * objDecl ) {
     886        DeclarationWithType *EliminateTypedef::mutate( ObjectDecl * objDecl ) {
    873887                TypedefMap oldNames = typedefNames;
    874                 ObjectDecl *ret = Mutator::mutate( objDecl );
     888                DeclarationWithType *ret = Mutator::mutate( objDecl );
     889                if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) {
     890                        return new FunctionDecl( ret->get_name(), ret->get_storageClass(), ret->get_linkage(), funtype, 0, ret->get_isInline(), ret->get_isNoreturn() );
     891                } else if ( objDecl->get_isInline() || objDecl->get_isNoreturn() ) {
     892                        throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl );
     893                } // if
    875894                typedefNames = oldNames;
    876895                return ret;
     
    936955        }
    937956
    938                 Declaration *EliminateTypedef::mutate( ContextDecl * contextDecl ) {
     957        Declaration *EliminateTypedef::mutate( ContextDecl * contextDecl ) {
    939958                Mutator::mutate( contextDecl );
    940959                return handleAggregate( contextDecl );
Note: See TracChangeset for help on using the changeset viewer.