Changeset 9f70ab57 for src/SymTab


Ignore:
Timestamp:
Sep 7, 2016, 11:30:02 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, 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, with_gc
Children:
02cea2d, 940bba3
Parents:
5fda7143
Message:

add forward declarations for autogenerated functions so that a struct becomes an otype as soon as its body is closed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r5fda7143 r9f70ab57  
    280280        }
    281281
     282        void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) {
     283                FunctionDecl * decl = functionDecl->clone();
     284                delete decl->get_statements();
     285                decl->set_statements( NULL );
     286                declsToAdd.push_back( decl );
     287                decl->fixUniqueId();
     288        }
     289
    282290        void makeStructFunctions( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd ) {
    283291                FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
     
    324332                copyCtorDecl->fixUniqueId();
    325333                dtorDecl->fixUniqueId();
     334
     335                if ( functionNesting == 0 ) {
     336                        // forward declare if top-level struct, so that
     337                        // type is complete as soon as its body ends
     338                        addForwardDecl( assignDecl, declsToAdd );
     339                        addForwardDecl( ctorDecl, declsToAdd );
     340                        addForwardDecl( copyCtorDecl, declsToAdd );
     341                        addForwardDecl( dtorDecl, declsToAdd );
     342                }
    326343
    327344                // create constructors which take each member type as a parameter.
Note: See TracChangeset for help on using the changeset viewer.