Changes in / [5fda7143:1f75e2d]


Ignore:
Location:
src
Files:
2 added
3 deleted
39 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.cc

    r5fda7143 r1f75e2d  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // SemanticError.cc --
     7// SemanticError.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    2626
    2727SemanticError::SemanticError( std::string error ) {
    28   append( error );
     28        errors.push_back( std::string( "Error: " ) + error );
    2929}
    3030
    3131void SemanticError::append( SemanticError &other ) {
    32   errors.splice( errors.end(), other.errors );
    33 }
    34 
    35 void SemanticError::append( const std::string & msg ) {
    36   errors.push_back( std::string( "Error: ") + msg );
     32        errors.splice( errors.end(), other.errors );
    3733}
    3834
  • src/Common/SemanticError.h

    r5fda7143 r1f75e2d  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // SemanticError.h --
     7// SemanticError.h -- 
    88//
    99// Author           : Richard C. Bilson
     
    3131
    3232        void append( SemanticError &other );
    33         void append( const std::string & );
    3433        bool isEmpty() const;
    3534        void print( std::ostream &os );
     
    4342template< typename T >
    4443SemanticError::SemanticError( const std::string &error, const T *obj ) {
    45         append( toString( error, obj ) );
     44        std::ostringstream os;
     45        os << "Error: " << error;
     46        obj->print( os );
     47        errors.push_back( os.str() );
    4648}
    47 
    4849
    4950#endif // SEMANTICERROR_H
  • src/Common/utility.h

    r5fda7143 r1f75e2d  
    265265std::weak_ptr<ThisType> RefCountSingleton<ThisType>::global_instance;
    266266
    267 // RAII object to regulate "save and restore" behaviour, e.g.
    268 // void Foo::bar() {
    269 //   ValueGuard<int> guard(var); // var is a member of type Foo
    270 //   var = ...;
    271 // } // var's original value is restored
    272 template< typename T >
    273 struct ValueGuard {
    274         T old;
    275         T& ref;
    276 
    277         ValueGuard(T& inRef) : old(inRef), ref(inRef) {}
    278         ~ValueGuard() { ref = old; }
    279 };
    280 
    281 template< typename T >
    282 struct reverseIterate_t {
    283         T& ref;
    284 
    285         reverseIterate_t( T & ref ) : ref(ref) {}
    286 
    287         typedef typename T::reverse_iterator iterator;
    288         iterator begin() { return ref.rbegin(); }
    289         iterator end() { return ref.rend(); }
    290 };
    291 
    292 template< typename T >
    293 reverseIterate_t< T > reverseIterate( T & ref ) {
    294         return reverseIterate_t< T >( ref );
    295 }
    296 
    297267#endif // _UTILITY_H
    298268
  • src/GenPoly/Box.cc

    r5fda7143 r1f75e2d  
    158158                class PolyGenericCalculator : public PolyMutator {
    159159                public:
    160                         typedef PolyMutator Parent;
    161                         using Parent::mutate;
    162 
    163160                        template< typename DeclClass >
    164161                        DeclClass *handleDecl( DeclClass *decl, Type *type );
     
    16781675                DeclClass * PolyGenericCalculator::handleDecl( DeclClass *decl, Type *type ) {
    16791676                        beginTypeScope( type );
    1680                         // knownLayouts.beginScope();
    1681                         // knownOffsets.beginScope();
    1682 
    1683                         DeclClass *ret = static_cast< DeclClass *>( Parent::mutate( decl ) );
    1684 
    1685                         // knownOffsets.endScope();
    1686                         // knownLayouts.endScope();
     1677                        knownLayouts.beginScope();
     1678                        knownOffsets.beginScope();
     1679
     1680                        DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) );
     1681
     1682                        knownOffsets.endScope();
     1683                        knownLayouts.endScope();
    16871684                        endTypeScope();
    16881685                        return ret;
     
    16941691
    16951692                DeclarationWithType * PolyGenericCalculator::mutate( FunctionDecl *functionDecl ) {
    1696                         knownLayouts.beginScope();
    1697                         knownOffsets.beginScope();
    1698 
    1699                         DeclarationWithType * decl = handleDecl( functionDecl, functionDecl->get_functionType() );
    1700                         knownOffsets.endScope();
    1701                         knownLayouts.endScope();
    1702                         return decl;
     1693                        return handleDecl( functionDecl, functionDecl->get_functionType() );
    17031694                }
    17041695
     
    17091700                TypeDecl * PolyGenericCalculator::mutate( TypeDecl *typeDecl ) {
    17101701                        scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
    1711                         return Parent::mutate( typeDecl );
     1702                        return Mutator::mutate( typeDecl );
    17121703                }
    17131704
     
    17151706                        beginTypeScope( pointerType );
    17161707
    1717                         Type *ret = Parent::mutate( pointerType );
     1708                        Type *ret = Mutator::mutate( pointerType );
    17181709
    17191710                        endTypeScope();
     
    17331724                        }
    17341725
    1735                         Type *ret = Parent::mutate( funcType );
     1726                        Type *ret = Mutator::mutate( funcType );
    17361727
    17371728                        endTypeScope();
     
    17541745                                }
    17551746                        }
    1756                         return Parent::mutate( declStmt );
     1747                        return Mutator::mutate( declStmt );
    17571748                }
    17581749
     
    17961787                Expression *PolyGenericCalculator::mutate( MemberExpr *memberExpr ) {
    17971788                        // mutate, exiting early if no longer MemberExpr
    1798                         Expression *expr = Parent::mutate( memberExpr );
     1789                        Expression *expr = Mutator::mutate( memberExpr );
    17991790                        memberExpr = dynamic_cast< MemberExpr* >( expr );
    18001791                        if ( ! memberExpr ) return expr;
     
    19811972                Expression *PolyGenericCalculator::mutate( OffsetofExpr *offsetofExpr ) {
    19821973                        // mutate, exiting early if no longer OffsetofExpr
    1983                         Expression *expr = Parent::mutate( offsetofExpr );
     1974                        Expression *expr = Mutator::mutate( offsetofExpr );
    19841975                        offsetofExpr = dynamic_cast< OffsetofExpr* >( expr );
    19851976                        if ( ! offsetofExpr ) return expr;
  • src/GenPoly/PolyMutator.cc

    r5fda7143 r1f75e2d  
    3030
    3131        void PolyMutator::mutateStatementList( std::list< Statement* > &statements ) {
    32                 SemanticError errors;
    33 
    3432                for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
    3533                        if ( ! stmtsToAddAfter.empty() ) {
    3634                                statements.splice( i, stmtsToAddAfter );
    3735                        } // if
    38                         try {
    39                                 *i = (*i)->acceptMutator( *this );
    40                         } catch ( SemanticError &e ) {
    41                                 errors.append( e );
    42                         } // try
     36                        *i = (*i)->acceptMutator( *this );
    4337                        if ( ! stmtsToAdd.empty() ) {
    4438                                statements.splice( i, stmtsToAdd );
     
    4842                        statements.splice( statements.end(), stmtsToAddAfter );
    4943                } // if
    50                 if ( ! errors.isEmpty() ) {
    51                         throw errors;
    52                 }
    5344        }
    5445
  • src/GenPoly/PolyMutator.h

    r5fda7143 r1f75e2d  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // PolyMutator.h --
     7// PolyMutator.h -- 
    88//
    99// Author           : Richard C. Bilson
     
    3030        class PolyMutator : public Mutator {
    3131          public:
    32                 typedef Mutator Parent;
    33                 using Parent::mutate;
    34 
    3532                PolyMutator();
    3633
     
    4542                virtual Statement* mutate(ExprStmt *catchStmt);
    4643                virtual Statement* mutate(ReturnStmt *catchStmt);
    47 
     44 
    4845                virtual Expression* mutate(UntypedExpr *untypedExpr);
    4946
     
    5754                Statement* mutateStatement( Statement *stmt );
    5855                Expression* mutateExpression( Expression *expr );
    59 
     56 
    6057                TyVarMap scopeTyVars;
    6158                TypeSubstitution *env;
     
    6360                std::list< Statement* > stmtsToAddAfter;
    6461        };
    65 } // namespace
     62} // namespace 
    6663
    6764#endif // _POLYMUTATOR_H
  • src/InitTweak/FixInit.cc

    r5fda7143 r1f75e2d  
    3131#include "SynTree/Mutator.h"
    3232#include "SymTab/Indexer.h"
    33 #include "SymTab/Autogen.h"
    3433#include "GenPoly/PolyMutator.h"
    3534#include "SynTree/AddStmtVisitor.h"
     
    177176                };
    178177
    179                 class GenStructMemberCalls : public SymTab::Indexer {
     178                class WarnStructMembers : public Visitor {
    180179                  public:
    181                         typedef Indexer Parent;
    182                         /// generate default/copy ctor and dtor calls for user-defined struct ctor/dtors
    183                         /// for any member that is missing a corresponding ctor/dtor call.
    184                         /// error if a member is used before constructed
    185                         static void generate( std::list< Declaration * > & translationUnit );
     180                        typedef Visitor Parent;
     181                        /// warn if a user-defined constructor or destructor is missing calls for
     182                        /// a struct member or if a member is used before constructed
     183                        static void warnings( std::list< Declaration * > & translationUnit );
    186184
    187185                        virtual void visit( FunctionDecl * funcDecl );
     
    190188                        virtual void visit( ApplicationExpr * appExpr );
    191189
    192                         SemanticError errors;
    193190                  private:
    194191                        void handleFirstParam( Expression * firstParam );
    195                         template< typename... Params >
    196                         void emit( const Params &... params );
    197192
    198193                        FunctionDecl * function = 0;
    199                         std::set< DeclarationWithType * > unhandled, usedUninit;
     194                        std::set< DeclarationWithType * > unhandled;
    200195                        ObjectDecl * thisParam = 0;
    201                         bool isCtor = false; // true if current function is a constructor
    202                         StructDecl * structDecl = 0;
    203                 };
    204 
    205                 // very simple resolver-like mutator class - used to
    206                 // resolve UntypedExprs that are found within newly
    207                 // generated constructor/destructor calls
    208                 class MutatingResolver : public Mutator {
    209                   public:
    210                         MutatingResolver( SymTab::Indexer & indexer ) : indexer( indexer ) {}
    211 
    212                         virtual DeclarationWithType* mutate( ObjectDecl *objectDecl );
    213 
    214                         virtual Expression* mutate( UntypedExpr *untypedExpr );
    215                         private:
    216                         SymTab::Indexer & indexer;
    217196                };
    218197        } // namespace
     
    230209                FixCopyCtors::fixCopyCtors( translationUnit );
    231210
    232                 GenStructMemberCalls::generate( translationUnit );
     211                WarnStructMembers::warnings( translationUnit );
    233212        }
    234213
     
    275254                }
    276255
    277                 void GenStructMemberCalls::generate( std::list< Declaration * > & translationUnit ) {
    278                         GenStructMemberCalls warner;
    279                         acceptAll( translationUnit, warner );
    280 
    281                         // visitor doesn't throw so that it can collect all errors
    282                         if ( ! warner.errors.isEmpty() ) {
    283                                 throw warner.errors;
     256                void WarnStructMembers::warnings( std::list< Declaration * > & translationUnit ) {
     257                        if ( true ) { // fix this condition to skip this pass if warnings aren't enabled
     258                                WarnStructMembers warner;
     259                                acceptAll( translationUnit, warner );
    284260                        }
    285261                }
     
    552528                                                        FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false );
    553529                                                        dtorCaller->fixUniqueId();
    554                                                         dtorCaller->get_statements()->push_back( dtorStmt );
     530                                                        dtorCaller->get_statements()->get_kids().push_back( dtorStmt );
    555531
    556532                                                        // atexit(dtor_atexit);
     
    567543                                                        // at global scope and there could be multiple function-scoped
    568544                                                        // static variables with the same name in different functions.
    569                                                         // Note: it isn't sufficient to modify only the mangleName, because
    570                                                         // then subsequent Indexer passes can choke on seeing the object's name
    571                                                         // if another object has the same name and type. An unfortunate side-effect
    572                                                         // of renaming the object is that subsequent NameExprs may fail to resolve,
    573                                                         // but there shouldn't be any remaining past this point.
    574545                                                        static UniqueName staticNamer( "_static_var" );
    575                                                         objDecl->set_name( objDecl->get_name() + staticNamer.newName() );
    576                                                         objDecl->set_mangleName( SymTab::Mangler::mangle( objDecl ) );
     546                                                        objDecl->set_mangleName( objDecl->get_mangleName() + staticNamer.newName() );
    577547
    578548                                                        objDecl->set_init( NULL );
     
    739709                }
    740710
    741                 void GenStructMemberCalls::visit( FunctionDecl * funcDecl ) {
    742                         ValueGuard< FunctionDecl * > oldFunction( funcDecl );
    743                         ValueGuard< std::set< DeclarationWithType * > > oldUnhandled( unhandled );
    744                         ValueGuard< std::set< DeclarationWithType * > > oldUsedUninit( usedUninit );
    745                         ValueGuard< ObjectDecl * > oldThisParam( thisParam );
    746                         ValueGuard< bool > oldIsCtor( isCtor );
    747                         ValueGuard< StructDecl * > oldStructDecl( structDecl );
    748 
    749                         // need to start with fresh sets
    750                         unhandled.clear();
    751                         usedUninit.clear();
     711                void WarnStructMembers::visit( FunctionDecl * funcDecl ) {
     712                        WarnStructMembers old = *this;
     713                        *this = WarnStructMembers();
    752714
    753715                        function = funcDecl;
    754                         isCtor = isConstructor( function->get_name() );
    755                         if ( checkWarnings( function ) ) {
    756                                 FunctionType * type = function->get_functionType();
     716                        if ( checkWarnings( funcDecl ) ) {
     717                                FunctionType * type = funcDecl->get_functionType();
    757718                                assert( ! type->get_parameters().empty() );
    758719                                thisParam = safe_dynamic_cast< ObjectDecl * >( type->get_parameters().front() );
     
    760721                                StructInstType * structType = dynamic_cast< StructInstType * >( ptrType->get_base() );
    761722                                if ( structType ) {
    762                                         structDecl = structType->get_baseStruct();
     723                                        StructDecl * structDecl = structType->get_baseStruct();
    763724                                        for ( Declaration * member : structDecl->get_members() ) {
    764725                                                if ( ObjectDecl * field = dynamic_cast< ObjectDecl * >( member ) ) {
     
    770731                                }
    771732                        }
    772                         Parent::visit( function );
    773 
    774                         // remove the unhandled objects from usedUninit, because a call is inserted
    775                         // to handle them - only objects that are later constructed are used uninitialized.
    776                         std::set< DeclarationWithType * > diff;
    777                         std::set_difference( usedUninit.begin(), usedUninit.end(), unhandled.begin(), unhandled.end(), std::inserter( diff, diff.begin() ) );
    778                         for ( DeclarationWithType * member : diff ) {
    779                                 emit( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", field ", member->get_name(), " used before being constructed" );
     733                        Parent::visit( funcDecl );
     734
     735                        for ( DeclarationWithType * member : unhandled ) {
     736                                // emit a warning for each unhandled member
     737                                warn( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", member->get_name(), " may not have been ", isConstructor( funcDecl->get_name() ) ? "constructed" : "destructed" );
    780738                        }
    781739
    782                         if ( ! unhandled.empty() ) {
    783                                 // need to explicitly re-add function parameters in order to resolve copy constructors
    784                                 enterScope();
    785                                 maybeAccept( function->get_functionType(), *this );
    786 
    787                                 // need to iterate through members in reverse in order for
    788                                 // ctor/dtor statements to come out in the right order
    789                                 for ( Declaration * member : reverseIterate( structDecl->get_members() ) ) {
    790                                         DeclarationWithType * field = dynamic_cast< DeclarationWithType * >( member );
    791                                         // skip non-DWT members
    792                                         if ( ! field ) continue;
    793                                         // skip handled members
    794                                         if ( ! unhandled.count( field ) ) continue;
    795 
    796                                         // insert and resolve default/copy constructor call for each field that's unhandled
    797                                         std::list< Statement * > stmt;
    798                                         UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
    799                                         deref->get_args().push_back( new VariableExpr( thisParam ) );
    800 
    801                                         Expression * arg2 = 0;
    802                                         if ( isCopyConstructor( function ) ) {
    803                                                 // if copy ctor, need to pass second-param-of-this-function.field
    804                                                 std::list< DeclarationWithType * > & params = function->get_functionType()->get_parameters();
    805                                                 assert( params.size() == 2 );
    806                                                 arg2 = new MemberExpr( field, new VariableExpr( params.back() ) );
    807                                         }
    808                                         InitExpander srcParam( arg2 );
    809                                         SymTab::genImplicitCall( srcParam, new MemberExpr( field, deref ), function->get_name(), back_inserter( stmt ), field, isCtor );
    810 
    811                                         assert( stmt.size() <= 1 );
    812                                         if ( stmt.size() == 1 ) {
    813                                                 Statement * callStmt = stmt.front();
    814 
    815                                                 MutatingResolver resolver( *this );
    816                                                 try {
    817                                                         callStmt->acceptMutator( resolver );
    818                                                         if ( isCtor ) {
    819                                                                 function->get_statements()->push_front( callStmt );
    820                                                         } else {
    821                                                                 // destructor statements should be added at the end
    822                                                                 function->get_statements()->push_back( callStmt );
    823                                                         }
    824                                                 } catch ( SemanticError & error ) {
    825                                                         emit( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", field ", field->get_name(), " not explicitly ", isCtor ? "constructed" : "destructed",  " and no ", isCtor ? "default constructor" : "destructor", " found" );
    826                                                 }
    827                                         }
    828                                 }
    829                                 leaveScope();
    830                         }
    831                 }
    832 
    833                 void GenStructMemberCalls::visit( ApplicationExpr * appExpr ) {
     740                        *this = old;
     741                }
     742
     743                void WarnStructMembers::visit( ApplicationExpr * appExpr ) {
    834744                        if ( ! checkWarnings( function ) ) return;
    835745
     
    850760                                        handleFirstParam( firstParam );
    851761                                }
     762                        } else if ( fname == "?=?" && isIntrinsicCallExpr( appExpr ) ) {
     763                                // forgive use of intrinsic assignment to construct, since instrinsic constructors
     764                                // codegen as assignment anyway.
     765                                assert( appExpr->get_args().size() == 2 );
     766                                handleFirstParam( appExpr->get_args().front() );
    852767                        }
    853768
     
    855770                }
    856771
    857                 void GenStructMemberCalls::handleFirstParam( Expression * firstParam ) {
     772                void WarnStructMembers::handleFirstParam( Expression * firstParam ) {
    858773                        using namespace std;
    859774                        if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( firstParam ) ) {
     
    872787                }
    873788
    874                 void GenStructMemberCalls::visit( MemberExpr * memberExpr ) {
     789                void WarnStructMembers::visit( MemberExpr * memberExpr ) {
    875790                        if ( ! checkWarnings( function ) ) return;
    876                         if ( ! isCtor ) return;
     791                        if ( ! isConstructor( function->get_name() ) ) return;
    877792
    878793                        if ( ApplicationExpr * deref = dynamic_cast< ApplicationExpr * >( memberExpr->get_aggregate() ) ) {
     
    882797                                                        if ( unhandled.count( memberExpr->get_member() ) ) {
    883798                                                                // emit a warning because a member was used before it was constructed
    884                                                                 usedUninit.insert( memberExpr->get_member() );
     799                                                                warn( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", memberExpr->get_member()->get_name(), " used before being constructed" );
    885800                                                        }
    886801                                                }
     
    890805                        Parent::visit( memberExpr );
    891806                }
    892 
    893                 template< typename Visitor, typename... Params >
    894                 void error( Visitor & v, const Params &... params ) {
    895                         v.errors.append( toString( params... ) );
    896                 }
    897 
    898                 template< typename... Params >
    899                 void GenStructMemberCalls::emit( const Params &... params ) {
    900                         // toggle warnings vs. errors here.
    901                         // warn( params... );
    902                         error( *this, params... );
    903                 }
    904 
    905                 DeclarationWithType * MutatingResolver::mutate( ObjectDecl *objectDecl ) {
    906                         // add object to the indexer assumes that there will be no name collisions
    907                         // in generated code. If this changes, add mutate methods for entities with
    908                         // scope and call {enter,leave}Scope explicitly.
    909                         objectDecl->accept( indexer );
    910                         return objectDecl;
    911                 }
    912 
    913                 Expression* MutatingResolver::mutate( UntypedExpr *untypedExpr ) {
    914                         return safe_dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untypedExpr, indexer ) );
    915                 }
    916807        } // namespace
    917808} // namespace InitTweak
  • src/InitTweak/GenInit.cc

    r5fda7143 r1f75e2d  
    2525#include "SynTree/Mutator.h"
    2626#include "SymTab/Autogen.h"
    27 #include "SymTab/Mangler.h"
    2827#include "GenPoly/PolyMutator.h"
    2928#include "GenPoly/DeclMutator.h"
    30 #include "GenPoly/ScopedSet.h"
    3129
    3230namespace InitTweak {
     
    5755        class CtorDtor : public GenPoly::PolyMutator {
    5856          public:
    59                 typedef GenPoly::PolyMutator Parent;
    60                 using Parent::mutate;
    6157                /// create constructor and destructor statements for object declarations.
    6258                /// the actual call statements will be added in after the resolver has run
     
    6965                // should not traverse into any of these declarations to find objects
    7066                // that need to be constructed or destructed
    71                 virtual Declaration* mutate( StructDecl *aggregateDecl );
     67                virtual Declaration* mutate( StructDecl *aggregateDecl ) { return aggregateDecl; }
    7268                virtual Declaration* mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; }
    7369                virtual Declaration* mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; }
     
    7874                virtual Type * mutate( FunctionType *funcType ) { return funcType; }
    7975
    80                 virtual CompoundStmt * mutate( CompoundStmt * compoundStmt );
    81 
    82           private:
    83                 // set of mangled type names for which a constructor or destructor exists in the current scope.
    84                 // these types require a ConstructorInit node to be generated, anything else is a POD type and thus
    85                 // should not have a ConstructorInit generated.
    86 
    87                 bool isManaged( ObjectDecl * objDecl ) const ; // determine if object is managed
    88                 void handleDWT( DeclarationWithType * dwt ); // add type to managed if ctor/dtor
    89                 GenPoly::ScopedSet< std::string > managedTypes;
    90                 bool inFunction = false;
     76          protected:
    9177        };
    9278
     
    156142
    157143        DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) {
    158                 ValueGuard< std::list<DeclarationWithType*> > oldReturnVals( returnVals );
    159                 ValueGuard< std::string > oldFuncName( funcName );
     144                std::list<DeclarationWithType*> oldReturnVals = returnVals;
     145                std::string oldFuncName = funcName;
    160146
    161147                FunctionType * type = functionDecl->get_functionType();
     
    163149                funcName = functionDecl->get_name();
    164150                DeclarationWithType * decl = Mutator::mutate( functionDecl );
     151                returnVals = oldReturnVals;
     152                funcName = oldFuncName;
    165153                return decl;
    166154        }
     
    209197
    210198        DeclarationWithType * HoistArrayDimension::mutate( FunctionDecl *functionDecl ) {
    211                 ValueGuard< bool > oldInFunc( inFunction );
     199                bool oldInFunc = inFunction;
    212200                inFunction = true;
    213201                DeclarationWithType * decl = Parent::mutate( functionDecl );
     202                inFunction = oldInFunc;
    214203                return decl;
    215204        }
     
    220209        }
    221210
    222         bool CtorDtor::isManaged( ObjectDecl * objDecl ) const {
    223                 Type * type = objDecl->get_type();
    224                 while ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
    225                         type = at->get_base();
    226                 }
    227                 return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end();
    228         }
    229 
    230         void CtorDtor::handleDWT( DeclarationWithType * dwt ) {
    231                 // if this function is a user-defined constructor or destructor, mark down the type as "managed"
    232                 if ( ! LinkageSpec::isOverridable( dwt->get_linkage() ) && isCtorDtor( dwt->get_name() ) ) {
    233                         std::list< DeclarationWithType * > & params = GenPoly::getFunctionType( dwt->get_type() )->get_parameters();
    234                         assert( ! params.empty() );
    235                         PointerType * type = safe_dynamic_cast< PointerType * >( params.front()->get_type() );
    236                         managedTypes.insert( SymTab::Mangler::mangle( type->get_base() ) );
    237                 }
    238         }
    239 
    240211        DeclarationWithType * CtorDtor::mutate( ObjectDecl * objDecl ) {
    241                 handleDWT( objDecl );
    242                 // hands off if @=, extern, builtin, etc.
    243                 // if global but initializer is not constexpr, always try to construct, since this is not legal C
    244                 if ( ( tryConstruct( objDecl ) && isManaged( objDecl ) ) || (! inFunction && ! isConstExpr( objDecl->get_init() ) ) ) {
    245                         // constructed objects cannot be designated
    246                         if ( isDesignated( objDecl->get_init() ) ) throw SemanticError( "Cannot include designations in the initializer for a managed Object. If this is really what you want, then initialize with @=.", objDecl );
    247                         // constructed objects should not have initializers nested too deeply
    248                         if ( ! checkInitDepth( objDecl ) ) throw SemanticError( "Managed object's initializer is too deep ", objDecl );
    249 
     212                // hands off if designated, if @=, or if extern
     213                if ( tryConstruct( objDecl ) ) {
    250214                        // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor
    251215                        // for each constructable object
     
    277241                        }
    278242                }
    279                 return Parent::mutate( objDecl );
     243                return Mutator::mutate( objDecl );
    280244        }
    281245
    282246        DeclarationWithType * CtorDtor::mutate( FunctionDecl *functionDecl ) {
    283                 ValueGuard< bool > oldInFunc = inFunction;
    284                 inFunction = true;
    285 
    286                 handleDWT( functionDecl );
    287 
    288                 managedTypes.beginScope();
    289                 // go through assertions and recursively add seen ctor/dtors
    290                 for ( TypeDecl * tyDecl : functionDecl->get_functionType()->get_forall() ) {
    291                         for ( DeclarationWithType *& assertion : tyDecl->get_assertions() ) {
    292                                 assertion = assertion->acceptMutator( *this );
    293                         }
    294                 }
    295247                // parameters should not be constructed and destructed, so don't mutate FunctionType
    296248                mutateAll( functionDecl->get_oldDecls(), *this );
    297249                functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
    298 
    299                 managedTypes.endScope();
    300250                return functionDecl;
    301251        }
    302 
    303         Declaration* CtorDtor::mutate( StructDecl *aggregateDecl ) {
    304                 // don't construct members, but need to take note if there is a managed member,
    305                 // because that means that this type is also managed
    306                 for ( Declaration * member : aggregateDecl->get_members() ) {
    307                         if ( ObjectDecl * field = dynamic_cast< ObjectDecl * >( member ) ) {
    308                                 if ( isManaged( field ) ) {
    309                                         managedTypes.insert( SymTab::Mangler::mangle( aggregateDecl ) );
    310                                         break;
    311                                 }
    312                         }
    313                 }
    314                 return aggregateDecl;
    315         }
    316 
    317         CompoundStmt * CtorDtor::mutate( CompoundStmt * compoundStmt ) {
    318                 managedTypes.beginScope();
    319                 CompoundStmt * stmt = Parent::mutate( compoundStmt );
    320                 managedTypes.endScope();
    321                 return stmt;
    322         }
    323 
    324252} // namespace InitTweak
    325253
  • src/InitTweak/InitTweak.cc

    r5fda7143 r1f75e2d  
    77#include "SynTree/Attribute.h"
    88#include "GenPoly/GenPoly.h"
    9 #include "ResolvExpr/typeops.h"
    109
    1110namespace InitTweak {
     
    2322                };
    2423
    25                 class InitDepthChecker : public Visitor {
    26                 public:
    27                         bool depthOkay = true;
    28                         Type * type;
    29                         int curDepth = 0, maxDepth = 0;
    30                         InitDepthChecker( Type * type ) : type( type ) {
    31                                 Type * t = type;
    32                                 while ( ArrayType * at = dynamic_cast< ArrayType * >( t ) ) {
    33                                         maxDepth++;
    34                                         t = at->get_base();
    35                                 }
    36                                 maxDepth++;
    37                         }
    38                         virtual void visit( ListInit * listInit ) {
    39                                 curDepth++;
    40                                 if ( curDepth > maxDepth ) depthOkay = false;
    41                                 Visitor::visit( listInit );
    42                                 curDepth--;
    43                         }
    44                 };
    45 
    4624                class InitFlattener : public Visitor {
    4725                        public:
     
    7452                maybeAccept( init, finder );
    7553                return finder.hasDesignations;
    76         }
    77 
    78         bool checkInitDepth( ObjectDecl * objDecl ) {
    79                 InitDepthChecker checker( objDecl->get_type() );
    80                 maybeAccept( objDecl->get_init(), checker );
    81                 return checker.depthOkay;
    8254        }
    8355
     
    259231                return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) &&
    260232                        (objDecl->get_init() == NULL ||
    261                                 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() ))
     233                                ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )) &&
     234                        ! isDesignated( objDecl->get_init() )
    262235                        && objDecl->get_storageClass() != DeclarationNode::Extern;
    263236        }
     
    417390                virtual void visit( ApplicationExpr *applicationExpr ) { isConstExpr = false; }
    418391                virtual void visit( UntypedExpr *untypedExpr ) { isConstExpr = false; }
    419                 virtual void visit( NameExpr *nameExpr ) {
    420                         // xxx - temporary hack, because 0 and 1 really should be constexprs, even though they technically aren't in Cforall today
    421                         if ( nameExpr->get_name() != "0" && nameExpr->get_name() != "1" ) isConstExpr = false;
    422                 }
    423                 // virtual void visit( CastExpr *castExpr ) { isConstExpr = false; }
    424                 virtual void visit( AddressExpr *addressExpr ) {
    425                         // address of a variable or member expression is constexpr
    426                         Expression * arg = addressExpr->get_arg();
    427                         if ( ! dynamic_cast< NameExpr * >( arg) && ! dynamic_cast< VariableExpr * >( arg ) && ! dynamic_cast< MemberExpr * >( arg ) && ! dynamic_cast< UntypedMemberExpr * >( arg ) ) isConstExpr = false;
    428                 }
     392                virtual void visit( NameExpr *nameExpr ) { isConstExpr = false; }
     393                virtual void visit( CastExpr *castExpr ) { isConstExpr = false; }
    429394                virtual void visit( LabelAddressExpr *labAddressExpr ) { isConstExpr = false; }
    430395                virtual void visit( UntypedMemberExpr *memberExpr ) { isConstExpr = false; }
    431396                virtual void visit( MemberExpr *memberExpr ) { isConstExpr = false; }
    432397                virtual void visit( VariableExpr *variableExpr ) { isConstExpr = false; }
     398                virtual void visit( ConstantExpr *constantExpr ) { /* bottom out */ }
    433399                // these might be okay?
    434400                // virtual void visit( SizeofExpr *sizeofExpr );
     
    473439        bool isDestructor( const std::string & str ) { return str == "^?{}"; }
    474440        bool isCtorDtor( const std::string & str ) { return isConstructor( str ) || isDestructor( str ); }
    475 
    476         FunctionDecl * isCopyConstructor( Declaration * decl ) {
    477                 FunctionDecl * function = dynamic_cast< FunctionDecl * >( decl );
    478                 if ( ! function ) return 0;
    479                 if ( ! isConstructor( function->get_name() ) ) return 0;
    480                 FunctionType * ftype = function->get_functionType();
    481                 if ( ftype->get_parameters().size() != 2 ) return 0;
    482 
    483                 Type * t1 = ftype->get_parameters().front()->get_type();
    484                 Type * t2 = ftype->get_parameters().back()->get_type();
    485                 PointerType * ptrType = dynamic_cast< PointerType * > ( t1 );
    486                 assert( ptrType );
    487 
    488                 if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) {
    489                         return function;
    490                 } else {
    491                         return 0;
    492                 }
    493         }
    494441}
  • src/InitTweak/InitTweak.h

    r5fda7143 r1f75e2d  
    3030        bool isCtorDtor( const std::string & );
    3131
    32         FunctionDecl * isCopyConstructor( Declaration * decl );
    33 
    3432        /// transform Initializer into an argument list that can be passed to a call expression
    3533        std::list< Expression * > makeInitList( Initializer * init );
     
    4038        /// True if the Initializer contains designations
    4139        bool isDesignated( Initializer * init );
    42 
    43         /// True if the ObjectDecl's Initializer nesting level is not deeper than the depth of its
    44         /// type, where the depth of its type is the number of nested ArrayTypes + 1
    45         bool checkInitDepth( ObjectDecl * objDecl );
    4640
    4741  /// Non-Null if expr is a call expression whose target function is intrinsic
  • src/Parser/DeclarationNode.cc

    r5fda7143 r1f75e2d  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 29 22:30:56 2016
    13 // Update Count     : 327
     12// Last Modified On : Sun Aug 28 22:12:44 2016
     13// Update Count     : 278
    1414//
    1515
     
    4242
    4343extern LinkageSpec::Spec linkage;                                               // defined in parser.yy
    44 
    45 DeclarationNode::DeclarationNode()
    46                 : type( 0 )
    47                 , storageClass( NoStorageClass )
    48                 , isInline( false )
    49                 , isNoreturn( false )
    50                 , bitfieldWidth( 0 )
    51                 , initializer( 0 )
    52                 , hasEllipsis( false )
    53                 , linkage( ::linkage )
    54                 , extension( false )
    55                 , error() {
    56         attr.expr = nullptr;
    57         attr.type = nullptr;
    58 
    59         variable.tyClass = DeclarationNode::Type;
    60         variable.assertions = nullptr;
    61 }
    62 
    63 DeclarationNode::~DeclarationNode() {
    64         delete attr.expr;
    65         delete attr.type;
    66         delete type;
    67         delete bitfieldWidth;
    68         delete initializer;
    69 }
    7044
    7145DeclarationNode *DeclarationNode::clone() const {
     
    8155        newnode->set_next( maybeClone( get_next() ) );
    8256        newnode->linkage = linkage;
    83 
    84         newnode->variable.assertions = maybeClone( variable.assertions );
    85         newnode->variable.name = variable.name;
    86         newnode->variable.tyClass = variable.tyClass;
    87 
    88         newnode->attr.expr = maybeClone( attr.expr );
    89         newnode->attr.type = maybeClone( attr.type );
    9057        return newnode;
    9158} // DeclarationNode::clone
     59
     60DeclarationNode::DeclarationNode()
     61        : type( 0 )
     62        , storageClass( NoStorageClass )
     63        , isInline( false )
     64        , isNoreturn( false )
     65        , bitfieldWidth( 0 )
     66        , initializer( 0 )
     67        , hasEllipsis( false )
     68        , linkage( ::linkage )
     69        , extension( false )
     70        , error() {
     71}
     72
     73DeclarationNode::~DeclarationNode() {
     74        delete type;
     75        delete bitfieldWidth;
     76        delete initializer;
     77}
    9278
    9379bool DeclarationNode::get_hasEllipsis() const {
     
    143129
    144130        newnode->type = new TypeData( TypeData::Function );
    145         newnode->type->function.params = param;
    146         newnode->type->function.newStyle = newStyle;
    147         newnode->type->function.body = body;
     131        newnode->type->function->params = param;
     132        newnode->type->function->newStyle = newStyle;
     133        newnode->type->function->body = body;
    148134        typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID );
    149135
    150136        if ( body ) {
    151                 newnode->type->function.hasBody = true;
     137                newnode->type->function->hasBody = true;
    152138        } // if
    153139
     
    189175        DeclarationNode *newnode = new DeclarationNode;
    190176        newnode->type = new TypeData( TypeData::Basic );
    191         newnode->type->basic.typeSpec.push_back( bt );
     177        newnode->type->basic->typeSpec.push_back( bt );
    192178        return newnode;
    193179} // DeclarationNode::newBasicType
     
    196182        DeclarationNode *newnode = new DeclarationNode;
    197183        newnode->type = new TypeData( TypeData::Basic );
    198         newnode->type->basic.modifiers.push_back( mod );
     184        newnode->type->basic->modifiers.push_back( mod );
    199185        return newnode;
    200186} // DeclarationNode::newModifier
    201187
     188DeclarationNode * DeclarationNode::newBuiltinType( BuiltinType bt ) {
     189        DeclarationNode *newnode = new DeclarationNode;
     190        newnode->type = new TypeData( TypeData::Builtin );
     191        newnode->type->builtin->type = bt;
     192        return newnode;
     193} // DeclarationNode::newBuiltinType
     194
    202195DeclarationNode * DeclarationNode::newFromTypedef( std::string *name ) {
    203196        DeclarationNode *newnode = new DeclarationNode;
    204197        newnode->type = new TypeData( TypeData::SymbolicInst );
    205         newnode->type->symbolic.name = assign_strptr( name );
    206         newnode->type->symbolic.isTypedef = true;
    207         newnode->type->symbolic.params = 0;
     198        newnode->type->symbolic->name = assign_strptr( name );
     199        newnode->type->symbolic->isTypedef = true;
     200        newnode->type->symbolic->params = 0;
    208201        return newnode;
    209202} // DeclarationNode::newFromTypedef
     
    212205        DeclarationNode *newnode = new DeclarationNode;
    213206        newnode->type = new TypeData( TypeData::Aggregate );
    214         newnode->type->aggregate.kind = kind;
    215         newnode->type->aggregate.name = assign_strptr( name );
    216         if ( newnode->type->aggregate.name == "" ) {            // anonymous aggregate ?
    217                 newnode->type->aggregate.name = anonymous.newName();
    218         } // if
    219         newnode->type->aggregate.actuals = actuals;
    220         newnode->type->aggregate.fields = fields;
    221         newnode->type->aggregate.body = body;
     207        newnode->type->aggregate->kind = kind;
     208        newnode->type->aggregate->name = assign_strptr( name );
     209        if ( newnode->type->aggregate->name == "" ) {           // anonymous aggregate ?
     210                newnode->type->aggregate->name = anonymous.newName();
     211        } // if
     212        newnode->type->aggregate->actuals = actuals;
     213        newnode->type->aggregate->fields = fields;
     214        newnode->type->aggregate->body = body;
    222215        return newnode;
    223216} // DeclarationNode::newAggregate
     
    227220        newnode->name = assign_strptr( name );
    228221        newnode->type = new TypeData( TypeData::Enum );
    229         newnode->type->enumeration.name = newnode->name;
    230         if ( newnode->type->enumeration.name == "" ) {          // anonymous enumeration ?
    231                 newnode->type->enumeration.name = DeclarationNode::anonymous.newName();
    232         } // if
    233         newnode->type->enumeration.constants = constants;
     222        newnode->type->enumeration->name = newnode->name;
     223        if ( newnode->type->enumeration->name == "" ) {         // anonymous enumeration ?
     224                newnode->type->enumeration->name = DeclarationNode::anonymous.newName();
     225        } // if
     226        newnode->type->enumeration->constants = constants;
    234227        return newnode;
    235228} // DeclarationNode::newEnum
     
    252245        DeclarationNode *newnode = new DeclarationNode;
    253246        newnode->type = new TypeData( TypeData::SymbolicInst );
    254         newnode->type->symbolic.name = assign_strptr( name );
    255         newnode->type->symbolic.isTypedef = false;
    256         newnode->type->symbolic.actuals = params;
     247        newnode->type->symbolic->name = assign_strptr( name );
     248        newnode->type->symbolic->isTypedef = false;
     249        newnode->type->symbolic->actuals = params;
    257250        return newnode;
    258251} // DeclarationNode::newFromTypeGen
     
    262255        newnode->name = assign_strptr( name );
    263256        newnode->type = new TypeData( TypeData::Variable );
    264         newnode->variable.tyClass = tc;
    265         newnode->variable.name = newnode->name;
     257        newnode->type->variable->tyClass = tc;
     258        newnode->type->variable->name = newnode->name;
    266259        return newnode;
    267260} // DeclarationNode::newTypeParam
     
    270263        DeclarationNode *newnode = new DeclarationNode;
    271264        newnode->type = new TypeData( TypeData::Aggregate );
    272         newnode->type->aggregate.kind = Trait;
    273         newnode->type->aggregate.params = params;
    274         newnode->type->aggregate.fields = asserts;
    275         newnode->type->aggregate.name = assign_strptr( name );
     265        newnode->type->aggregate->kind = Trait;
     266        newnode->type->aggregate->params = params;
     267        newnode->type->aggregate->fields = asserts;
     268        newnode->type->aggregate->name = assign_strptr( name );
    276269        return newnode;
    277270} // DeclarationNode::newTrait
     
    280273        DeclarationNode *newnode = new DeclarationNode;
    281274        newnode->type = new TypeData( TypeData::AggregateInst );
    282         newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate );
    283         newnode->type->aggInst.aggregate->aggregate.kind = Trait;
    284         newnode->type->aggInst.aggregate->aggregate.name = assign_strptr( name );
    285         newnode->type->aggInst.params = params;
     275        newnode->type->aggInst->aggregate = new TypeData( TypeData::Aggregate );
     276        newnode->type->aggInst->aggregate->aggregate->kind = Trait;
     277        newnode->type->aggInst->aggregate->aggregate->name = assign_strptr( name );
     278        newnode->type->aggInst->params = params;
    286279        return newnode;
    287280} // DeclarationNode::newTraitUse
     
    291284        newnode->name = assign_strptr( name );
    292285        newnode->type = new TypeData( TypeData::Symbolic );
    293         newnode->type->symbolic.isTypedef = false;
    294         newnode->type->symbolic.params = typeParams;
    295         newnode->type->symbolic.name = newnode->name;
     286        newnode->type->symbolic->isTypedef = false;
     287        newnode->type->symbolic->params = typeParams;
     288        newnode->type->symbolic->name = newnode->name;
    296289        return newnode;
    297290} // DeclarationNode::newTypeDecl
     
    306299        DeclarationNode *newnode = new DeclarationNode;
    307300        newnode->type = new TypeData( TypeData::Array );
    308         newnode->type->array.dimension = size;
    309         newnode->type->array.isStatic = isStatic;
    310         if ( newnode->type->array.dimension == 0 || newnode->type->array.dimension->isExpressionType<ConstantExpr *>() ) {
    311                 newnode->type->array.isVarLen = false;
     301        newnode->type->array->dimension = size;
     302        newnode->type->array->isStatic = isStatic;
     303        if ( newnode->type->array->dimension == 0 || newnode->type->array->dimension->isExpressionType<ConstantExpr *>() ) {
     304                newnode->type->array->isVarLen = false;
    312305        } else {
    313                 newnode->type->array.isVarLen = true;
     306                newnode->type->array->isVarLen = true;
    314307        } // if
    315308        return newnode->addQualifiers( qualifiers );
     
    319312        DeclarationNode *newnode = new DeclarationNode;
    320313        newnode->type = new TypeData( TypeData::Array );
    321         newnode->type->array.dimension = 0;
    322         newnode->type->array.isStatic = false;
    323         newnode->type->array.isVarLen = true;
     314        newnode->type->array->dimension = 0;
     315        newnode->type->array->isStatic = false;
     316        newnode->type->array->isVarLen = true;
    324317        return newnode->addQualifiers( qualifiers );
    325318}
     
    334327        DeclarationNode *newnode = new DeclarationNode;
    335328        newnode->type = new TypeData( TypeData::Tuple );
    336         newnode->type->tuple = members;
     329        newnode->type->tuple->members = members;
    337330        return newnode;
    338331}
     
    341334        DeclarationNode *newnode = new DeclarationNode;
    342335        newnode->type = new TypeData( TypeData::Typeof );
    343         newnode->type->typeexpr = expr;
    344         return newnode;
    345 }
    346 
    347 DeclarationNode * DeclarationNode::newBuiltinType( BuiltinType bt ) {
    348         DeclarationNode *newnode = new DeclarationNode;
    349         newnode->type = new TypeData( TypeData::Builtin );
    350         newnode->builtin = bt;
    351         return newnode;
    352 } // DeclarationNode::newBuiltinType
     336        newnode->type->typeexpr->expr = expr;
     337        return newnode;
     338}
    353339
    354340DeclarationNode *DeclarationNode::newAttr( std::string *name, ExpressionNode *expr ) {
    355341        DeclarationNode *newnode = new DeclarationNode;
    356342        newnode->type = new TypeData( TypeData::Attr );
    357         newnode->attr.name = assign_strptr( name );
    358         newnode->attr.expr = expr;
     343        newnode->type->attr->name = assign_strptr( name );
     344        newnode->type->attr->expr = expr;
    359345        return newnode;
    360346}
     
    363349        DeclarationNode *newnode = new DeclarationNode;
    364350        newnode->type = new TypeData( TypeData::Attr );
    365         newnode->attr.name = assign_strptr( name );
    366         newnode->attr.type = type;
     351        newnode->type->attr->name = assign_strptr( name );
     352        newnode->type->attr->type = type;
    367353        return newnode;
    368354}
     
    421407                                } else {
    422408                                        if ( type->kind == TypeData::Aggregate ) {
    423                                                 type->aggregate.params = q->type->forall;
     409                                                type->aggregate->params = q->type->forall;
    424410                                                // change implicit typedef from TYPEDEFname to TYPEGENname
    425                                                 typedefTable.changeKind( type->aggregate.name, TypedefTable::TG );
     411                                                typedefTable.changeKind( type->aggregate->name, TypedefTable::TG );
    426412                                        } else {
    427413                                                type->forall = q->type->forall;
     
    471457                                if ( src->kind != TypeData::Unknown ) {
    472458                                        assert( src->kind == TypeData::Basic );
    473                                         dst->basic.modifiers.splice( dst->basic.modifiers.end(), src->basic.modifiers );
    474                                         dst->basic.typeSpec.splice( dst->basic.typeSpec.end(), src->basic.typeSpec );
     459                                        dst->basic->modifiers.splice( dst->basic->modifiers.end(), src->basic->modifiers );
     460                                        dst->basic->typeSpec.splice( dst->basic->typeSpec.end(), src->basic->typeSpec );
    475461                                } // if
    476462                                break;
     
    480466                                  case TypeData::Enum:
    481467                                        dst->base = new TypeData( TypeData::AggregateInst );
    482                                         dst->base->aggInst.aggregate = src;
     468                                        dst->base->aggInst->aggregate = src;
    483469                                        if ( src->kind == TypeData::Aggregate ) {
    484                                                 dst->base->aggInst.params = maybeClone( src->aggregate.actuals );
     470                                                dst->base->aggInst->params = maybeClone( src->aggregate->actuals );
    485471                                        } // if
    486472                                        dst->base->qualifiers |= src->qualifiers;
     
    509495                                if ( o->type->kind == TypeData::Aggregate || o->type->kind == TypeData::Enum ) {
    510496                                        type = new TypeData( TypeData::AggregateInst );
    511                                         type->aggInst.aggregate = o->type;
     497                                        type->aggInst->aggregate = o->type;
    512498                                        if ( o->type->kind == TypeData::Aggregate ) {
    513                                                 type->aggInst.params = maybeClone( o->type->aggregate.actuals );
     499                                                type->aggInst->params = maybeClone( o->type->aggregate->actuals );
    514500                                        } // if
    515501                                        type->qualifiers |= o->type->qualifiers;
     
    537523DeclarationNode *DeclarationNode::addTypedef() {
    538524        TypeData *newtype = new TypeData( TypeData::Symbolic );
    539         newtype->symbolic.params = 0;
    540         newtype->symbolic.isTypedef = true;
    541         newtype->symbolic.name = name;
     525        newtype->symbolic->params = 0;
     526        newtype->symbolic->isTypedef = true;
     527        newtype->symbolic->name = name;
    542528        newtype->base = type;
    543529        type = newtype;
     
    549535        switch ( type->kind ) {
    550536          case TypeData::Symbolic:
    551                 if ( type->symbolic.assertions ) {
    552                         type->symbolic.assertions->appendList( assertions );
     537                if ( type->symbolic->assertions ) {
     538                        type->symbolic->assertions->appendList( assertions );
    553539                } else {
    554                         type->symbolic.assertions = assertions;
     540                        type->symbolic->assertions = assertions;
    555541                } // if
    556542                break;
    557543          case TypeData::Variable:
    558                 if ( variable.assertions ) {
    559                         variable.assertions->appendList( assertions );
     544                if ( type->variable->assertions ) {
     545                        type->variable->assertions->appendList( assertions );
    560546                } else {
    561                         variable.assertions = assertions;
     547                        type->variable->assertions = assertions;
    562548                } // if
    563549                break;
     
    588574        assert( type );
    589575        assert( type->kind == TypeData::Function );
    590         assert( type->function.body == 0 );
    591         type->function.body = body;
    592         type->function.hasBody = true;
     576        assert( type->function->body == 0 );
     577        type->function->body = body;
     578        type->function->hasBody = true;
    593579        return this;
    594580}
     
    597583        assert( type );
    598584        assert( type->kind == TypeData::Function );
    599         assert( type->function.oldDeclList == 0 );
    600         type->function.oldDeclList = list;
     585        assert( type->function->oldDeclList == 0 );
     586        type->function->oldDeclList = list;
    601587        return this;
    602588}
     
    644630                          case TypeData::Enum:
    645631                                p->type->base = new TypeData( TypeData::AggregateInst );
    646                                 p->type->base->aggInst.aggregate = type;
     632                                p->type->base->aggInst->aggregate = type;
    647633                                if ( type->kind == TypeData::Aggregate ) {
    648                                         p->type->base->aggInst.params = maybeClone( type->aggregate.actuals );
     634                                        p->type->base->aggInst->params = maybeClone( type->aggregate->actuals );
    649635                                } // if
    650636                                p->type->base->qualifiers |= type->qualifiers;
     
    681667                          case TypeData::Enum:
    682668                                lastArray->base = new TypeData( TypeData::AggregateInst );
    683                                 lastArray->base->aggInst.aggregate = type;
     669                                lastArray->base->aggInst->aggregate = type;
    684670                                if ( type->kind == TypeData::Aggregate ) {
    685                                         lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals );
     671                                        lastArray->base->aggInst->params = maybeClone( type->aggregate->actuals );
    686672                                } // if
    687673                                lastArray->base->qualifiers |= type->qualifiers;
     
    701687DeclarationNode *DeclarationNode::addParamList( DeclarationNode *params ) {
    702688        TypeData *ftype = new TypeData( TypeData::Function );
    703         ftype->function.params = params;
     689        ftype->function->params = params;
    704690        setBase( type, ftype );
    705691        return this;
     
    711697                        type->base = addIdListToType( type->base, ids );
    712698                } else {
    713                         type->function.idList = ids;
     699                        type->function->idList = ids;
    714700                } // if
    715701                return type;
    716702        } else {
    717703                TypeData *newtype = new TypeData( TypeData::Function );
    718                 newtype->function.idList = ids;
     704                newtype->function->idList = ids;
    719705                return newtype;
    720706        } // if
     
    741727        if ( newnode->type->kind == TypeData::AggregateInst ) {
    742728                // don't duplicate members
    743                 if ( newnode->type->aggInst.aggregate->kind == TypeData::Enum ) {
    744                         delete newnode->type->aggInst.aggregate->enumeration.constants;
    745                         newnode->type->aggInst.aggregate->enumeration.constants = 0;
     729                if ( newnode->type->aggInst->aggregate->kind == TypeData::Enum ) {
     730                        delete newnode->type->aggInst->aggregate->enumeration->constants;
     731                        newnode->type->aggInst->aggregate->enumeration->constants = 0;
    746732                } else {
    747                         assert( newnode->type->aggInst.aggregate->kind == TypeData::Aggregate );
    748                         delete newnode->type->aggInst.aggregate->aggregate.fields;
    749                         newnode->type->aggInst.aggregate->aggregate.fields = 0;
     733                        assert( newnode->type->aggInst->aggregate->kind == TypeData::Aggregate );
     734                        delete newnode->type->aggInst->aggregate->aggregate->fields;
     735                        newnode->type->aggInst->aggregate->aggregate->fields = 0;
    750736                } // if
    751737        } // if
     
    767753                        if ( newType->kind == TypeData::AggregateInst ) {
    768754                                // don't duplicate members
    769                                 if ( newType->aggInst.aggregate->kind == TypeData::Enum ) {
    770                                         delete newType->aggInst.aggregate->enumeration.constants;
    771                                         newType->aggInst.aggregate->enumeration.constants = 0;
     755                                if ( newType->aggInst->aggregate->kind == TypeData::Enum ) {
     756                                        delete newType->aggInst->aggregate->enumeration->constants;
     757                                        newType->aggInst->aggregate->enumeration->constants = 0;
    772758                                } else {
    773                                         assert( newType->aggInst.aggregate->kind == TypeData::Aggregate );
    774                                         delete newType->aggInst.aggregate->aggregate.fields;
    775                                         newType->aggInst.aggregate->aggregate.fields = 0;
     759                                        assert( newType->aggInst->aggregate->kind == TypeData::Aggregate );
     760                                        delete newType->aggInst->aggregate->aggregate->fields;
     761                                        newType->aggInst->aggregate->aggregate->fields = 0;
    776762                                } // if
    777763                        } // if
     
    910896        if ( ! error.empty() ) throw SemanticError( error, this );
    911897        if ( type ) {
    912                 if ( type->kind == TypeData::Variable ) {
    913                         static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype };
    914                         TypeDecl * ret = new TypeDecl( variable.name, DeclarationNode::NoStorageClass, 0, kindMap[ variable.tyClass ] );
    915                         buildList( variable.assertions, ret->get_assertions() );
    916                         return ret;
    917                 } else {
    918                         return buildDecl( type, name, storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension );
    919                 } // if
     898                return buildDecl( type, name, storageClass, maybeBuild< Expression >( bitfieldWidth ), isInline, isNoreturn, linkage, maybeBuild< Initializer >(initializer) )->set_extension( extension );
    920899        } // if
    921900        if ( ! isInline && ! isNoreturn ) {
     
    930909        switch ( type->kind ) {
    931910          case TypeData::Enum:
    932                 return new EnumInstType( buildQualifiers( type ), type->enumeration.name );
     911                return new EnumInstType( buildQualifiers( type ), type->enumeration->name );
    933912          case TypeData::Aggregate: {
    934913                  ReferenceToType *ret;
    935                   switch ( type->aggregate.kind ) {
     914                  switch ( type->aggregate->kind ) {
    936915                        case DeclarationNode::Struct:
    937                           ret = new StructInstType( buildQualifiers( type ), type->aggregate.name );
     916                          ret = new StructInstType( buildQualifiers( type ), type->aggregate->name );
    938917                          break;
    939918                        case DeclarationNode::Union:
    940                           ret = new UnionInstType( buildQualifiers( type ), type->aggregate.name );
     919                          ret = new UnionInstType( buildQualifiers( type ), type->aggregate->name );
    941920                          break;
    942921                        case DeclarationNode::Trait:
    943                           ret = new TraitInstType( buildQualifiers( type ), type->aggregate.name );
     922                          ret = new TraitInstType( buildQualifiers( type ), type->aggregate->name );
    944923                          break;
    945924                        default:
    946925                          assert( false );
    947926                  } // switch
    948                   buildList( type->aggregate.actuals, ret->get_parameters() );
     927                  buildList( type->aggregate->actuals, ret->get_parameters() );
    949928                  return ret;
    950929          }
    951930          case TypeData::Symbolic: {
    952                   TypeInstType *ret = new TypeInstType( buildQualifiers( type ), type->symbolic.name, false );
    953                   buildList( type->symbolic.actuals, ret->get_parameters() );
    954                   return ret;
    955           }
    956           case TypeData::Attr: {
    957                   assert( type->kind == TypeData::Attr );
    958                   // assert( type->attr );
    959                   AttrType * ret;
    960                   if ( attr.expr ) {
    961                           ret = new AttrType( buildQualifiers( type ), attr.name, attr.expr->build() );
    962                   } else {
    963                           assert( attr.type );
    964                           ret = new AttrType( buildQualifiers( type ), attr.name, attr.type->buildType() );
    965                   } // if
     931                  TypeInstType *ret = new TypeInstType( buildQualifiers( type ), type->symbolic->name, false );
     932                  buildList( type->symbolic->actuals, ret->get_parameters() );
    966933                  return ret;
    967934          }
  • src/Parser/ParseNode.cc

    r5fda7143 r1f75e2d  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ParseNode.cc --
     7// ParseNode.cc -- 
    88//
    99// Author           : Rodolfo G. Esteves
     
    1212// Last Modified On : Wed Aug 17 23:14:16 2016
    1313// Update Count     : 126
    14 //
     14// 
    1515
    1616#include "ParseNode.h"
     
    1919int ParseNode::indent_by = 4;
    2020
    21 std::ostream & operator<<( std::ostream & out, const ParseNode * node ) {
    22   node->print( out );
    23   return out;
    24 }
    25 
    2621// Local Variables: //
    2722// tab-width: 4 //
  • src/Parser/ParseNode.h

    r5fda7143 r1f75e2d  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 29 21:45:43 2016
    13 // Update Count     : 583
     12// Last Modified On : Sun Aug 28 21:14:51 2016
     13// Update Count     : 575
    1414//
    1515
     
    290290        // bool buildFuncSpecifier( StorageClass key ) const;
    291291
    292         struct Enumeration_t {
    293                 std::string name;
    294                 DeclarationNode * constants;
    295         };
    296         Enumeration_t enumeration;
    297 
    298         struct Variable_t {
    299                 DeclarationNode::TypeClass tyClass;
    300                 std::string name;
    301                 DeclarationNode * assertions;
    302         };
    303         Variable_t variable;
    304 
    305         struct Attr_t {
    306                 std::string name;
    307                 ExpressionNode * expr;
    308                 DeclarationNode * type;
    309         };
    310         Attr_t attr;
    311 
    312         BuiltinType builtin;
    313 
    314292        TypeData *type;
    315293        std::string name;
     
    431409}
    432410
    433 // in ParseNode.cc
    434 std::ostream & operator<<( std::ostream & out, const ParseNode * node );
    435411
    436412#endif // PARSENODE_H
  • src/Parser/TypeData.cc

    r5fda7143 r1f75e2d  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 29 22:31:53 2016
    13 // Update Count     : 277
     12// Last Modified On : Sun Aug 28 18:28:58 2016
     13// Update Count     : 223
    1414//
    1515
     
    3333                break;
    3434          case Basic:
    35                 // basic = new Basic_t;
     35                basic = new Basic_t;
    3636                break;
    3737          case Array:
    38                 // array = new Array_t;
    39                 array.dimension = 0;
    40                 array.isVarLen = false;
    41                 array.isStatic = false;
     38                array = new Array_t;
     39                array->dimension = 0;
     40                array->isVarLen = false;
     41                array->isStatic = false;
    4242                break;
    4343          case Function:
    44                 // function = new Function_t;
    45                 function.params = 0;
    46                 function.idList = 0;
    47                 function.oldDeclList = 0;
    48                 function.body = 0;
    49                 function.hasBody = false;
    50                 function.newStyle = false;
     44                function = new Function_t;
     45                function->params = 0;
     46                function->idList = 0;
     47                function->oldDeclList = 0;
     48                function->body = 0;
     49                function->hasBody = false;
     50                function->newStyle = false;
    5151                break;
    5252          case Aggregate:
    53                 // aggregate = new Aggregate_t;
    54                 aggregate.params = 0;
    55                 aggregate.actuals = 0;
    56                 aggregate.fields = 0;
     53                aggregate = new Aggregate_t;
     54                aggregate->params = 0;
     55                aggregate->actuals = 0;
     56                aggregate->fields = 0;
    5757                break;
    5858          case AggregateInst:
    59                 // aggInst = new AggInst_t;
    60                 aggInst.aggregate = 0;
    61                 aggInst.params = 0;
     59                aggInst = new AggInst_t;
     60                aggInst->aggregate = 0;
     61                aggInst->params = 0;
    6262                break;
    6363          case Enum:
    64                 // enumeration = new Enumeration_t;
    65                 enumeration.constants = 0;
     64                enumeration = new Enumeration_t;
     65                enumeration->constants = 0;
    6666                break;
    6767          case Symbolic:
    6868          case SymbolicInst:
    69                 // symbolic = new Symbolic_t;
    70                 symbolic.params = 0;
    71                 symbolic.actuals = 0;
    72                 symbolic.assertions = 0;
     69                symbolic = new Symbolic_t;
     70                symbolic->params = 0;
     71                symbolic->actuals = 0;
     72                symbolic->assertions = 0;
    7373                break;
    7474          case Variable:
    75                 // variable = new Variable_t;
    76                 // variable.tyClass = DeclarationNode::Type;
    77                 // variable.assertions = 0;
     75                variable = new Variable_t;
     76                variable->tyClass = DeclarationNode::Type;
     77                variable->assertions = 0;
    7878                break;
    7979          case Tuple:
    80                 // tuple = new Tuple_t;
    81                 tuple = nullptr;
     80                tuple = new Tuple_t;
     81                tuple->members = 0;
    8282                break;
    8383          case Typeof:
    84                 // typeexpr = new Typeof_t;
    85                 typeexpr = nullptr;
     84                typeexpr = new Typeof_t;
     85                typeexpr->expr = 0;
     86                break;
     87          case Builtin:
     88                builtin = new Builtin_t;
    8689                break;
    8790          case Attr:
    88                 // attr = new Attr_t;
    89                 // attr.expr = nullptr;
    90                 // attr.type = nullptr;
    91                 break;
    92           case Builtin:
    93                 // builtin = new Builtin_t;
     91                attr = new Attr_t;
     92                attr->expr = 0;
     93                attr->type = 0;
    9494                break;
    9595        } // switch
     
    107107                break;
    108108          case Basic:
    109                 // delete basic;
     109                delete basic;
    110110                break;
    111111          case Array:
    112                 delete array.dimension;
    113                 // delete array;
     112                delete array->dimension;
     113                delete array;
    114114                break;
    115115          case Function:
    116                 delete function.params;
    117                 delete function.idList;
    118                 delete function.oldDeclList;
    119                 delete function.body;
    120                 // delete function;
     116                delete function->params;
     117                delete function->idList;
     118                delete function->oldDeclList;
     119                delete function->body;
     120                delete function;
    121121                break;
    122122          case Aggregate:
    123                 delete aggregate.params;
    124                 delete aggregate.actuals;
    125                 delete aggregate.fields;
    126                 // delete aggregate;
     123                delete aggregate->params;
     124                delete aggregate->actuals;
     125                delete aggregate->fields;
     126                delete aggregate;
    127127                break;
    128128          case AggregateInst:
    129                 delete aggInst.aggregate;
    130                 delete aggInst.params;
    131                 // delete aggInst;
     129                delete aggInst->aggregate;
     130                delete aggInst->params;
     131                delete aggInst;
    132132                break;
    133133          case Enum:
    134                 delete enumeration.constants;
    135                 // delete enumeration;
     134                delete enumeration->constants;
     135                delete enumeration;
    136136                break;
    137137          case Symbolic:
    138138          case SymbolicInst:
    139                 delete symbolic.params;
    140                 delete symbolic.actuals;
    141                 delete symbolic.assertions;
    142                 // delete symbolic;
     139                delete symbolic->params;
     140                delete symbolic->actuals;
     141                delete symbolic->assertions;
     142                delete symbolic;
    143143                break;
    144144          case Variable:
    145                 // delete variable.assertions;
    146                 // delete variable;
     145                delete variable->assertions;
     146                delete variable;
    147147                break;
    148148          case Tuple:
    149                 // delete tuple->members;
     149                delete tuple->members;
    150150                delete tuple;
    151151                break;
    152152          case Typeof:
    153                 // delete typeexpr->expr;
     153                delete typeexpr->expr;
    154154                delete typeexpr;
    155155                break;
     156          case Builtin:
     157                delete builtin;
     158                break;
    156159          case Attr:
    157                 // delete attr.expr;
    158                 // delete attr.type;
    159                 // delete attr;
    160                 break;
    161           case Builtin:
    162                 // delete builtin;
     160                delete attr->expr;
     161                delete attr->type;
     162                delete attr;
    163163                break;
    164164        } // switch
     
    178178                break;
    179179          case Basic:
    180                 newtype->basic.typeSpec = basic.typeSpec;
    181                 newtype->basic.modifiers = basic.modifiers;
     180                newtype->basic->typeSpec = basic->typeSpec;
     181                newtype->basic->modifiers = basic->modifiers;
    182182                break;
    183183          case Array:
    184                 newtype->array.dimension = maybeClone( array.dimension );
    185                 newtype->array.isVarLen = array.isVarLen;
    186                 newtype->array.isStatic = array.isStatic;
     184                newtype->array->dimension = maybeClone( array->dimension );
     185                newtype->array->isVarLen = array->isVarLen;
     186                newtype->array->isStatic = array->isStatic;
    187187                break;
    188188          case Function:
    189                 newtype->function.params = maybeClone( function.params );
    190                 newtype->function.idList = maybeClone( function.idList );
    191                 newtype->function.oldDeclList = maybeClone( function.oldDeclList );
    192                 newtype->function.body = maybeClone( function.body );
    193                 newtype->function.hasBody = function.hasBody;
    194                 newtype->function.newStyle = function.newStyle;
     189                newtype->function->params = maybeClone( function->params );
     190                newtype->function->idList = maybeClone( function->idList );
     191                newtype->function->oldDeclList = maybeClone( function->oldDeclList );
     192                newtype->function->body = maybeClone( function->body );
     193                newtype->function->hasBody = function->hasBody;
     194                newtype->function->newStyle = function->newStyle;
    195195                break;
    196196          case Aggregate:
    197                 newtype->aggregate.params = maybeClone( aggregate.params );
    198                 newtype->aggregate.actuals = maybeClone( aggregate.actuals );
    199                 newtype->aggregate.fields = maybeClone( aggregate.fields );
    200                 newtype->aggregate.name = aggregate.name;
    201                 newtype->aggregate.kind = aggregate.kind;
    202                 newtype->aggregate.body = aggregate.body;
     197                newtype->aggregate->params = maybeClone( aggregate->params );
     198                newtype->aggregate->actuals = maybeClone( aggregate->actuals );
     199                newtype->aggregate->fields = maybeClone( aggregate->fields );
     200                newtype->aggregate->name = aggregate->name;
     201                newtype->aggregate->kind = aggregate->kind;
     202                newtype->aggregate->body = aggregate->body;
    203203                break;
    204204          case AggregateInst:
    205                 newtype->aggInst.aggregate = maybeClone( aggInst.aggregate );
    206                 newtype->aggInst.params = maybeClone( aggInst.params );
     205                newtype->aggInst->aggregate = maybeClone( aggInst->aggregate );
     206                newtype->aggInst->params = maybeClone( aggInst->params );
    207207                break;
    208208          case Enum:
    209                 newtype->enumeration.name = enumeration.name;
    210                 newtype->enumeration.constants = maybeClone( enumeration.constants );
     209                newtype->enumeration->name = enumeration->name;
     210                newtype->enumeration->constants = maybeClone( enumeration->constants );
    211211                break;
    212212          case Symbolic:
    213213          case SymbolicInst:
    214                 newtype->symbolic.params = maybeClone( symbolic.params );
    215                 newtype->symbolic.actuals = maybeClone( symbolic.actuals );
    216                 newtype->symbolic.assertions = maybeClone( symbolic.assertions );
    217                 newtype->symbolic.isTypedef = symbolic.isTypedef;
    218                 newtype->symbolic.name = symbolic.name;
     214                newtype->symbolic->params = maybeClone( symbolic->params );
     215                newtype->symbolic->actuals = maybeClone( symbolic->actuals );
     216                newtype->symbolic->assertions = maybeClone( symbolic->assertions );
     217                newtype->symbolic->isTypedef = symbolic->isTypedef;
     218                newtype->symbolic->name = symbolic->name;
    219219                break;
    220220          case Variable:
    221                 assert( false );
    222                 // newtype->variable.assertions = maybeClone( variable.assertions );
    223                 // newtype->variable.name = variable.name;
    224                 // newtype->variable.tyClass = variable.tyClass;
     221                newtype->variable->assertions = maybeClone( variable->assertions );
     222                newtype->variable->name = variable->name;
     223                newtype->variable->tyClass = variable->tyClass;
    225224                break;
    226225          case Tuple:
    227                 newtype->tuple = maybeClone( tuple );
     226                newtype->tuple->members = maybeClone( tuple->members );
    228227                break;
    229228          case Typeof:
    230                 newtype->typeexpr = maybeClone( typeexpr );
     229                newtype->typeexpr->expr = maybeClone( typeexpr->expr );
     230                break;
     231          case Builtin:
     232                newtype->builtin->type = builtin->type;
    231233                break;
    232234          case Attr:
    233                 assert( false );
    234                 // newtype->attr.expr = maybeClone( attr.expr );
    235                 // newtype->attr.type = maybeClone( attr.type );
    236                 break;
    237           case Builtin:
    238                 assert( false );
    239                 // newtype->builtin = builtin;
     235                newtype->attr->expr = maybeClone( attr->expr );
     236                newtype->attr->type = maybeClone( attr->type );
    240237                break;
    241238        } // switch
     
    271268                break;
    272269          case Basic:
    273                 printEnums( basic.modifiers.begin(), basic.modifiers.end(), DeclarationNode::modifierName, os );
    274                 printEnums( basic.typeSpec.begin(), basic.typeSpec.end(), DeclarationNode::basicTypeName, os );
     270                printEnums( basic->modifiers.begin(), basic->modifiers.end(), DeclarationNode::modifierName, os );
     271                printEnums( basic->typeSpec.begin(), basic->typeSpec.end(), DeclarationNode::basicTypeName, os );
    275272                break;
    276273          case Array:
    277                 if ( array.isStatic ) {
     274                if ( array->isStatic ) {
    278275                        os << "static ";
    279276                } // if
    280                 if ( array.dimension ) {
     277                if ( array->dimension ) {
    281278                        os << "array of ";
    282                         array.dimension->printOneLine( os, indent );
    283                 } else if ( array.isVarLen ) {
     279                        array->dimension->printOneLine( os, indent );
     280                } else if ( array->isVarLen ) {
    284281                        os << "variable-length array of ";
    285282                } else {
     
    292289          case Function:
    293290                os << "function" << endl;
    294                 if ( function.params ) {
     291                if ( function->params ) {
    295292                        os << string( indent + 2, ' ' ) << "with parameters " << endl;
    296                         function.params->printList( os, indent + 4 );
     293                        function->params->printList( os, indent + 4 );
    297294                } else {
    298295                        os << string( indent + 2, ' ' ) << "with no parameters " << endl;
    299296                } // if
    300                 if ( function.idList ) {
     297                if ( function->idList ) {
    301298                        os << string( indent + 2, ' ' ) << "with old-style identifier list " << endl;
    302                         function.idList->printList( os, indent + 4 );
    303                 } // if
    304                 if ( function.oldDeclList ) {
     299                        function->idList->printList( os, indent + 4 );
     300                } // if
     301                if ( function->oldDeclList ) {
    305302                        os << string( indent + 2, ' ' ) << "with old-style declaration list " << endl;
    306                         function.oldDeclList->printList( os, indent + 4 );
     303                        function->oldDeclList->printList( os, indent + 4 );
    307304                } // if
    308305                os << string( indent + 2, ' ' ) << "returning ";
     
    313310                } // if
    314311                os << endl;
    315                 if ( function.hasBody ) {
     312                if ( function->hasBody ) {
    316313                        os << string( indent + 2, ' ' ) << "with body " << endl;
    317314                } // if
    318                 if ( function.body ) {
    319                         function.body->printList( os, indent + 2 );
     315                if ( function->body ) {
     316                        function->body->printList( os, indent + 2 );
    320317                } // if
    321318                break;
    322319          case Aggregate:
    323                 os << DeclarationNode::aggregateName[ aggregate.kind ] << ' ' << aggregate.name << endl;
    324                 if ( aggregate.params ) {
     320                os << DeclarationNode::aggregateName[ aggregate->kind ] << ' ' << aggregate->name << endl;
     321                if ( aggregate->params ) {
    325322                        os << string( indent + 2, ' ' ) << "with type parameters " << endl;
    326                         aggregate.params->printList( os, indent + 4 );
    327                 } // if
    328                 if ( aggregate.actuals ) {
     323                        aggregate->params->printList( os, indent + 4 );
     324                } // if
     325                if ( aggregate->actuals ) {
    329326                        os << string( indent + 2, ' ' ) << "instantiated with actual parameters " << endl;
    330                         aggregate.actuals->printList( os, indent + 4 );
    331                 } // if
    332                 if ( aggregate.fields ) {
     327                        aggregate->actuals->printList( os, indent + 4 );
     328                } // if
     329                if ( aggregate->fields ) {
    333330                        os << string( indent + 2, ' ' ) << "with members " << endl;
    334                         aggregate.fields->printList( os, indent + 4 );
    335                 } // if
    336                 if ( aggregate.body ) {
     331                        aggregate->fields->printList( os, indent + 4 );
     332                } // if
     333                if ( aggregate->body ) {
    337334                        os << string( indent + 2, ' ' ) << " with body " << endl;
    338335                } // if
    339336                break;
    340337          case AggregateInst:
    341                 if ( aggInst.aggregate ) {
     338                if ( aggInst->aggregate ) {
    342339                        os << "instance of " ;
    343                         aggInst.aggregate->print( os, indent );
     340                        aggInst->aggregate->print( os, indent );
    344341                } else {
    345342                        os << "instance of an unspecified aggregate ";
    346343                } // if
    347                 if ( aggInst.params ) {
     344                if ( aggInst->params ) {
    348345                        os << string( indent + 2, ' ' ) << "with parameters " << endl;
    349                         aggInst.params->printList( os, indent + 2 );
     346                        aggInst->params->printList( os, indent + 2 );
    350347                } // if
    351348                break;
    352349          case Enum:
    353350                os << "enumeration ";
    354                 if ( enumeration.constants ) {
     351                if ( enumeration->constants ) {
    355352                        os << "with constants" << endl;
    356                         enumeration.constants->printList( os, indent + 2 );
     353                        enumeration->constants->printList( os, indent + 2 );
    357354                } // if
    358355                break;
    359356          case SymbolicInst:
    360                 os << "instance of type " << symbolic.name;
    361                 if ( symbolic.actuals ) {
     357                os << "instance of type " << symbolic->name;
     358                if ( symbolic->actuals ) {
    362359                        os << " with parameters" << endl;
    363                         symbolic.actuals->printList( os, indent + 2 );
     360                        symbolic->actuals->printList( os, indent + 2 );
    364361                } // if
    365362                break;
    366363          case Symbolic:
    367                 if ( symbolic.isTypedef ) {
     364                if ( symbolic->isTypedef ) {
    368365                        os << "typedef definition ";
    369366                } else {
    370367                        os << "type definition ";
    371368                } // if
    372                 if ( symbolic.params ) {
     369                if ( symbolic->params ) {
    373370                        os << endl << string( indent + 2, ' ' ) << "with parameters" << endl;
    374                         symbolic.params->printList( os, indent + 2 );
    375                 } // if
    376                 if ( symbolic.assertions ) {
     371                        symbolic->params->printList( os, indent + 2 );
     372                } // if
     373                if ( symbolic->assertions ) {
    377374                        os << endl << string( indent + 2, ' ' ) << "with assertions" << endl;
    378                         symbolic.assertions->printList( os, indent + 4 );
     375                        symbolic->assertions->printList( os, indent + 4 );
    379376                        os << string( indent + 2, ' ' );
    380377                } // if
     
    385382                break;
    386383          case Variable:
    387                 // os << DeclarationNode::typeClassName[ variable.tyClass ] << " variable ";
    388                 // if ( variable.assertions ) {
    389                 //      os << endl << string( indent + 2, ' ' ) << "with assertions" << endl;
    390                 //      variable.assertions->printList( os, indent + 4 );
    391                 //      os << string( indent + 2, ' ' );
    392                 // } // if
     384                os << DeclarationNode::typeClassName[ variable->tyClass ] << " variable ";
     385                if ( variable->assertions ) {
     386                        os << endl << string( indent + 2, ' ' ) << "with assertions" << endl;
     387                        variable->assertions->printList( os, indent + 4 );
     388                        os << string( indent + 2, ' ' );
     389                } // if
    393390                break;
    394391          case Tuple:
    395392                os << "tuple ";
    396                 if ( tuple ) {
     393                if ( tuple->members ) {
    397394                        os << "with members " << endl;
    398                         tuple->printList( os, indent + 2 );
     395                        tuple->members->printList( os, indent + 2 );
    399396                } // if
    400397                break;
    401398          case Typeof:
    402399                os << "type-of expression ";
    403                 if ( typeexpr ) {
    404                         typeexpr->print( os, indent + 2 );
     400                if ( typeexpr->expr ) {
     401                        typeexpr->expr->print( os, indent + 2 );
    405402                } // if
    406403                break;
    407404          case Attr:
    408                 // os << "attribute type decl " << attr.name << " applied to ";
    409                 // if ( attr.expr ) {
    410                 //      attr.expr->print( os, indent + 2 );
    411                 // } // if
    412                 // if ( attr.type ) {
    413                 //      attr.type->print( os, indent + 2 );
    414                 // } // if
     405                os << "attribute type decl " << attr->name << " applied to ";
     406                if ( attr->expr ) {
     407                        attr->expr->print( os, indent + 2 );
     408                } // if
     409                if ( attr->type ) {
     410                        attr->type->print( os, indent + 2 );
     411                } // if
    415412                break;
    416413          case Builtin:
     
    482479                return new VarArgsType( buildQualifiers( td ) );
    483480          case TypeData::Attr:
    484                 assert( false );
    485481                return buildAttr( td );
    486482          case TypeData::Symbolic:
     
    498494        switch ( td->kind ) {
    499495          case TypeData::Aggregate:
    500                 if ( ! toplevel && td->aggregate.fields ) {
     496                if ( ! toplevel && td->aggregate->fields ) {
    501497                        ret = td->clone();
    502498                } // if
    503499                break;
    504500          case TypeData::Enum:
    505                 if ( ! toplevel && td->enumeration.constants ) {
     501                if ( ! toplevel && td->enumeration->constants ) {
    506502                        ret = td->clone();
    507503                } // if
    508504                break;
    509505          case TypeData::AggregateInst:
    510                 if ( td->aggInst.aggregate ) {
    511                         ret = typeextractAggregate( td->aggInst.aggregate, false );
     506                if ( td->aggInst->aggregate ) {
     507                        ret = typeextractAggregate( td->aggInst->aggregate, false );
    512508                } // if
    513509                break;
     
    539535        BasicType::Kind ret;
    540536
    541         for ( std::list< DeclarationNode::BasicType >::const_iterator i = td->basic.typeSpec.begin(); i != td->basic.typeSpec.end(); ++i ) {
     537        for ( std::list< DeclarationNode::BasicType >::const_iterator i = td->basic->typeSpec.begin(); i != td->basic->typeSpec.end(); ++i ) {
    542538                if ( ! init ) {
    543539                        init = true;
    544540                        if ( *i == DeclarationNode::Void ) {
    545                                 if ( td->basic.typeSpec.size() != 1 || ! td->basic.modifiers.empty() ) {
     541                                if ( td->basic->typeSpec.size() != 1 || ! td->basic->modifiers.empty() ) {
    546542                                        throw SemanticError( "invalid type specifier \"void\" in type: ", td );
    547543                                } else {
     
    615611        } // for
    616612
    617         for ( std::list< DeclarationNode::Modifier >::const_iterator i = td->basic.modifiers.begin(); i != td->basic.modifiers.end(); ++i ) {
     613        for ( std::list< DeclarationNode::Modifier >::const_iterator i = td->basic->modifiers.begin(); i != td->basic->modifiers.end(); ++i ) {
    618614                switch ( *i ) {
    619615                  case DeclarationNode::Long:
     
    750746        ArrayType * at;
    751747        if ( td->base ) {
    752                 at = new ArrayType( buildQualifiers( td ), typebuild( td->base ), maybeBuild< Expression >( td->array.dimension ),
    753                                                         td->array.isVarLen, td->array.isStatic );
     748                at = new ArrayType( buildQualifiers( td ), typebuild( td->base ), maybeBuild< Expression >( td->array->dimension ),
     749                                                        td->array->isVarLen, td->array->isStatic );
    754750        } else {
    755751                at = new ArrayType( buildQualifiers( td ), new BasicType( Type::Qualifiers(), BasicType::SignedInt ),
    756                                                         maybeBuild< Expression >( td->array.dimension ), td->array.isVarLen, td->array.isStatic );
     752                                                        maybeBuild< Expression >( td->array->dimension ), td->array->isVarLen, td->array->isStatic );
    757753        } // if
    758754        buildForall( td->forall, at->get_forall() );
     
    763759        assert( td->kind == TypeData::Aggregate );
    764760        AggregateDecl * at;
    765         switch ( td->aggregate.kind ) {
     761        switch ( td->aggregate->kind ) {
    766762          case DeclarationNode::Struct:
    767                 at = new StructDecl( td->aggregate.name );
    768                 buildForall( td->aggregate.params, at->get_parameters() );
     763                at = new StructDecl( td->aggregate->name );
     764                buildForall( td->aggregate->params, at->get_parameters() );
    769765                break;
    770766          case DeclarationNode::Union:
    771                 at = new UnionDecl( td->aggregate.name );
    772                 buildForall( td->aggregate.params, at->get_parameters() );
     767                at = new UnionDecl( td->aggregate->name );
     768                buildForall( td->aggregate->params, at->get_parameters() );
    773769                break;
    774770          case DeclarationNode::Trait:
    775                 at = new TraitDecl( td->aggregate.name );
    776                 buildList( td->aggregate.params, at->get_parameters() );
     771                at = new TraitDecl( td->aggregate->name );
     772                buildList( td->aggregate->params, at->get_parameters() );
    777773                break;
    778774          default:
     
    780776        } // switch
    781777
    782         buildList( td->aggregate.fields, at->get_members() );
    783         at->set_body( td->aggregate.body );
     778        buildList( td->aggregate->fields, at->get_members() );
     779        at->set_body( td->aggregate->body );
    784780
    785781        return at;
     
    790786
    791787        ReferenceToType * ret;
    792         if ( td->aggInst.aggregate->kind == TypeData::Enum ) {
    793                 ret = new EnumInstType( buildQualifiers( td ), td->aggInst.aggregate->enumeration.name );
     788        if ( td->aggInst->aggregate->kind == TypeData::Enum ) {
     789                ret = new EnumInstType( buildQualifiers( td ), td->aggInst->aggregate->enumeration->name );
    794790        } else {
    795                 assert( td->aggInst.aggregate->kind == TypeData::Aggregate );
    796                 switch ( td->aggInst.aggregate->aggregate.kind ) {
     791                assert( td->aggInst->aggregate->kind == TypeData::Aggregate );
     792                switch ( td->aggInst->aggregate->aggregate->kind ) {
    797793                  case DeclarationNode::Struct:
    798                         ret = new StructInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name );
     794                        ret = new StructInstType( buildQualifiers( td ), td->aggInst->aggregate->aggregate->name );
    799795                        break;
    800796                  case DeclarationNode::Union:
    801                         ret = new UnionInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name );
     797                        ret = new UnionInstType( buildQualifiers( td ), td->aggInst->aggregate->aggregate->name );
    802798                        break;
    803799                  case DeclarationNode::Trait:
    804                         ret = new TraitInstType( buildQualifiers( td ), td->aggInst.aggregate->aggregate.name );
     800                        ret = new TraitInstType( buildQualifiers( td ), td->aggInst->aggregate->aggregate->name );
    805801                        break;
    806802                  default:
     
    808804                } // switch
    809805        } // if
    810         buildList( td->aggInst.params, ret->get_parameters() );
     806        buildList( td->aggInst->params, ret->get_parameters() );
    811807        buildForall( td->forall, ret->get_forall() );
    812808        return ret;
     
    817813        NamedTypeDecl * ret;
    818814        assert( td->base );
    819         if ( td->symbolic.isTypedef ) {
     815        if ( td->symbolic->isTypedef ) {
    820816                ret = new TypedefDecl( name, sc, typebuild( td->base ) );
    821817        } else {
    822818                ret = new TypeDecl( name, sc, typebuild( td->base ), TypeDecl::Any );
    823819        } // if
    824         buildList( td->symbolic.params, ret->get_parameters() );
    825         buildList( td->symbolic.assertions, ret->get_assertions() );
     820        buildList( td->symbolic->params, ret->get_parameters() );
     821        buildList( td->symbolic->assertions, ret->get_assertions() );
    826822        return ret;
    827823} // buildSymbolic
    828824
    829825TypeDecl * buildVariable( const TypeData * td ) {
    830         assert( false );
    831         return nullptr;
    832         // assert( td->kind == TypeData::Variable );
    833         // static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype };
    834 
    835         // TypeDecl * ret = new TypeDecl( td->variable.name, DeclarationNode::NoStorageClass, 0, kindMap[ td->variable.tyClass ] );
    836         // buildList( td->variable.assertions, ret->get_assertions() );
    837         // return ret;
     826        assert( td->kind == TypeData::Variable );
     827        static const TypeDecl::Kind kindMap[] = { TypeDecl::Any, TypeDecl::Ftype, TypeDecl::Dtype };
     828
     829        TypeDecl * ret = new TypeDecl( td->variable->name, DeclarationNode::NoStorageClass, 0, kindMap[ td->variable->tyClass ] );
     830        buildList( td->variable->assertions, ret->get_assertions() );
     831        return ret;
    838832} // buildSymbolic
    839833
    840834EnumDecl * buildEnum( const TypeData * td ) {
    841835        assert( td->kind == TypeData::Enum );
    842         EnumDecl * ret = new EnumDecl( td->enumeration.name );
    843         buildList( td->enumeration.constants, ret->get_members() );
     836        EnumDecl * ret = new EnumDecl( td->enumeration->name );
     837        buildList( td->enumeration->constants, ret->get_members() );
    844838        std::list< Declaration * >::iterator members = ret->get_members().begin();
    845         for ( const DeclarationNode * cur = td->enumeration. constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {
     839        for ( const DeclarationNode * cur = td->enumeration-> constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {
    846840                if ( cur->has_enumeratorValue() ) {
    847841                        ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members);
     
    854848TypeInstType * buildSymbolicInst( const TypeData * td ) {
    855849        assert( td->kind == TypeData::SymbolicInst );
    856         TypeInstType * ret = new TypeInstType( buildQualifiers( td ), td->symbolic.name, false );
    857         buildList( td->symbolic.actuals, ret->get_parameters() );
     850        TypeInstType * ret = new TypeInstType( buildQualifiers( td ), td->symbolic->name, false );
     851        buildList( td->symbolic->actuals, ret->get_parameters() );
    858852        buildForall( td->forall, ret->get_forall() );
    859853        return ret;
     
    863857        assert( td->kind == TypeData::Tuple );
    864858        TupleType * ret = new TupleType( buildQualifiers( td ) );
    865         buildTypeList( td->tuple, ret->get_types() );
     859        buildTypeList( td->tuple->members, ret->get_types() );
    866860        buildForall( td->forall, ret->get_forall() );
    867861        return ret;
     
    871865        assert( td->kind == TypeData::Typeof );
    872866        assert( td->typeexpr );
    873         // assert( td->typeexpr->expr );
    874         return new TypeofType( buildQualifiers( td ), td->typeexpr->build() );
     867        assert( td->typeexpr->expr );
     868        return new TypeofType( buildQualifiers( td ), td->typeexpr->expr->build() );
    875869} // buildTypeof
    876870
    877871AttrType * buildAttr( const TypeData * td ) {
    878         assert( false );
    879         return nullptr;
    880         // assert( td->kind == TypeData::Attr );
    881         // // assert( td->attr );
    882         // AttrType * ret;
    883         // if ( td->attr.expr ) {
    884         //      ret = new AttrType( buildQualifiers( td ), td->attr.name, td->attr.expr->build() );
    885         // } else {
    886         //      assert( td->attr.type );
    887         //      ret = new AttrType( buildQualifiers( td ), td->attr.name, td->attr.type->buildType() );
    888         // } // if
    889         // return ret;
     872        assert( td->kind == TypeData::Attr );
     873        assert( td->attr );
     874        AttrType * ret;
     875        if ( td->attr->expr ) {
     876                ret = new AttrType( buildQualifiers( td ), td->attr->name, td->attr->expr->build() );
     877        } else {
     878                assert( td->attr->type );
     879                ret = new AttrType( buildQualifiers( td ), td->attr->name, td->attr->type->buildType() );
     880        } // if
     881        return ret;
    890882} // buildAttr
    891883
     
    893885        if ( td->kind == TypeData::Function ) {
    894886                FunctionDecl * decl;
    895                 if ( td->function.hasBody ) {
    896                         if ( td->function.body ) {
    897                                 Statement * stmt = td->function.body->build();
     887                if ( td->function->hasBody ) {
     888                        if ( td->function->body ) {
     889                                Statement * stmt = td->function->body->build();
    898890                                CompoundStmt * body = dynamic_cast< CompoundStmt* >( stmt );
    899891                                assert( body );
     
    906898                        decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), 0, isInline, isNoreturn );
    907899                } // if
    908                 for ( DeclarationNode * cur = td->function.idList; cur != 0; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) {
     900                for ( DeclarationNode * cur = td->function->idList; cur != 0; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) {
    909901                        if ( cur->get_name() != "" ) {
    910902                                decl->get_oldIdents().insert( decl->get_oldIdents().end(), cur->get_name() );
    911903                        } // if
    912904                } // for
    913                 buildList( td->function.oldDeclList, decl->get_oldDecls() );
     905                buildList( td->function->oldDeclList, decl->get_oldDecls() );
    914906                return decl;
    915907        } else if ( td->kind == TypeData::Aggregate ) {
     
    920912                return buildSymbolic( td, name, sc );
    921913        } else if ( td->kind == TypeData::Variable ) {
    922                 assert( false );
    923914                return buildVariable( td );
    924915        } else {
     
    930921FunctionType * buildFunction( const TypeData * td ) {
    931922        assert( td->kind == TypeData::Function );
    932         bool hasEllipsis = td->function.params ? td->function.params->get_hasEllipsis() : true;
    933         if ( ! td->function.params ) hasEllipsis = ! td->function.newStyle;
     923        bool hasEllipsis = td->function->params ? td->function->params->get_hasEllipsis() : true;
     924        if ( ! td->function->params ) hasEllipsis = ! td->function->newStyle;
    934925        FunctionType * ft = new FunctionType( buildQualifiers( td ), hasEllipsis );
    935         buildList( td->function.params, ft->get_parameters() );
     926        buildList( td->function->params, ft->get_parameters() );
    936927        buildForall( td->forall, ft->get_forall() );
    937928        if ( td->base ) {
    938929                switch ( td->base->kind ) {
    939930                  case TypeData::Tuple:
    940                         buildList( td->base->tuple, ft->get_returnVals() );
     931                        buildList( td->base->tuple->members, ft->get_returnVals() );
    941932                        break;
    942933                  default:
  • src/Parser/TypeData.h

    r5fda7143 r1f75e2d  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 29 22:31:52 2016
    13 // Update Count     : 110
     12// Last Modified On : Sun Aug 28 22:39:00 2016
     13// Update Count     : 85
    1414//
    1515
     
    2424struct TypeData {
    2525        enum Kind { Unknown, Basic, Pointer, Array, Function, Aggregate, AggregateInst,
    26                                 Enum, EnumConstant, Symbolic, SymbolicInst, Variable, Tuple, Typeof, Builtin, Attr };
     26                                Enum, EnumConstant, Symbolic, SymbolicInst, Variable, Tuple, Typeof, Builtin, Attr } kind;
    2727
    2828        struct Basic_t {
     
    7373        };
    7474
    75         // struct Tuple_t {
    76         //      DeclarationNode * members;
    77         // };
     75        struct Variable_t {
     76                DeclarationNode::TypeClass tyClass;
     77                std::string name;
     78                DeclarationNode * assertions;
     79        };
     80
     81        struct Tuple_t {
     82                DeclarationNode * members;
     83        };
    7884 
    79         // struct Typeof_t {
    80         //      ExpressionNode * expr;
    81         // };
     85        struct Typeof_t {
     86                ExpressionNode * expr;
     87        };
    8288
    83         // struct Builtin_t {
    84         //      DeclarationNode::BuiltinType type;
    85         // };
     89        struct Builtin_t {
     90                DeclarationNode::BuiltinType type;
     91        };
    8692
    87         Kind kind;
     93        struct Attr_t {
     94                std::string name;
     95                ExpressionNode * expr;
     96                DeclarationNode * type;
     97        };
     98
    8899        TypeData * base;
    89100        typedef std::bitset< DeclarationNode::NoOfQualifier > Qualifiers;
     
    91102        DeclarationNode * forall;
    92103
    93                 Basic_t basic;
    94                 Aggregate_t aggregate;
    95                 AggInst_t aggInst;
    96                 Array_t array;
    97                 Enumeration_t enumeration;
    98                 Function_t function;
    99                 Symbolic_t symbolic;
    100                 DeclarationNode * tuple;
    101                 ExpressionNode * typeexpr;
    102                 //Attr_t attr;
    103                 // DeclarationNode::BuiltinType builtin;
     104        union {
     105                Basic_t * basic;
     106                Aggregate_t * aggregate;
     107                AggInst_t * aggInst;
     108                Array_t * array;
     109                Enumeration_t * enumeration;
     110                Function_t * function;
     111                Symbolic_t * symbolic;
     112                Variable_t * variable;
     113                Tuple_t * tuple;
     114                Typeof_t * typeexpr;
     115                Attr_t * attr;
     116                Builtin_t * builtin;
     117        };
    104118
    105119        TypeData( Kind k = Unknown );
  • src/ResolvExpr/AlternativeFinder.cc

    r5fda7143 r1f75e2d  
    4242#include "Common/utility.h"
    4343#include "InitTweak/InitTweak.h"
    44 #include "ResolveTypeof.h"
    4544
    4645extern bool resolvep;
     
    708707        void AlternativeFinder::visit( CastExpr *castExpr ) {
    709708                for ( std::list< Type* >::iterator i = castExpr->get_results().begin(); i != castExpr->get_results().end(); ++i ) {
    710                         *i = resolveTypeof( *i, indexer );
    711709                        SymTab::validateType( *i, &indexer );
    712710                        adjustExprType( *i, env, indexer );
     
    797795
    798796        void AlternativeFinder::visit( VariableExpr *variableExpr ) {
    799                 // not sufficient to clone here, because variable's type may have changed
    800                 // since the VariableExpr was originally created.
    801                 alternatives.push_back( Alternative( new VariableExpr( variableExpr->get_var() ), env, Cost::zero ) );
     797                alternatives.push_back( Alternative( variableExpr->clone(), env, Cost::zero ) );
    802798        }
    803799
     
    808804        void AlternativeFinder::visit( SizeofExpr *sizeofExpr ) {
    809805                if ( sizeofExpr->get_isType() ) {
    810                         // xxx - resolveTypeof?
    811806                        alternatives.push_back( Alternative( sizeofExpr->clone(), env, Cost::zero ) );
    812807                } else {
     
    828823        void AlternativeFinder::visit( AlignofExpr *alignofExpr ) {
    829824                if ( alignofExpr->get_isType() ) {
    830                         // xxx - resolveTypeof?
    831825                        alternatives.push_back( Alternative( alignofExpr->clone(), env, Cost::zero ) );
    832826                } else {
     
    862856        void AlternativeFinder::visit( UntypedOffsetofExpr *offsetofExpr ) {
    863857                AlternativeFinder funcFinder( indexer, env );
    864                 // xxx - resolveTypeof?
    865858                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( offsetofExpr->get_type() ) ) {
    866859                        addOffsetof( structInst, offsetofExpr->get_member() );
  • src/ResolvExpr/Resolver.cc

    r5fda7143 r1f75e2d  
    528528
    529529        void Resolver::visit( ConstructorInit *ctorInit ) {
    530                 // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit
    531                 maybeAccept( ctorInit->get_ctor(), *this );
    532                 maybeAccept( ctorInit->get_dtor(), *this );
     530                try {
     531                        maybeAccept( ctorInit->get_ctor(), *this );
     532                        maybeAccept( ctorInit->get_dtor(), *this );
     533                } catch ( SemanticError ) {
     534                        // no alternatives for the constructor initializer - fallback on C-style initializer
     535                        // xxx - not sure if this makes a ton of sense - should maybe never be able to have this situation?
     536                        fallbackInit( ctorInit );
     537                        return;
     538                }
    533539
    534540                // found a constructor - can get rid of C-style initializer
  • src/SymTab/Autogen.h

    r5fda7143 r1f75e2d  
    102102                }
    103103
    104                 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );
     104                ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), NULL );
     105
     106                UntypedExpr *init = new UntypedExpr( new NameExpr( "?=?" ) );
     107                init->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
     108                init->get_args().push_back( begin );
     109                index->set_init( new SingleInit( init, std::list<Expression*>() ) );
    105110
    106111                UntypedExpr *cond = new UntypedExpr( cmp );
  • src/SymTab/Indexer.cc

    r5fda7143 r1f75e2d  
    2121#include <unordered_set>
    2222#include <utility>
    23 #include <algorithm>
    2423
    2524#include "Mangler.h"
     
    3433#include "SynTree/Initializer.h"
    3534#include "SynTree/Statement.h"
    36 
    37 #include "InitTweak/InitTweak.h"
    3835
    3936#define debugPrint(x) if ( doDebug ) { std::cout << x; }
     
    104101        }
    105102
    106         void Indexer::removeSpecialOverrides( const std::string &id, std::list< DeclarationWithType * > & out ) const {
    107                 // only need to perform this step for constructors and destructors
    108                 if ( ! InitTweak::isCtorDtor( id ) ) return;
    109 
    110                 // helpful data structure
    111                 struct ValueType {
    112                         struct DeclBall {
    113                                 FunctionDecl * decl;
    114                                 bool isUserDefinedFunc; // properties for this particular decl
    115                                 bool isDefaultFunc;
    116                                 bool isCopyFunc;
    117                         };
    118                         // properties for this type
    119                         bool userDefinedFunc = false; // any user defined function found
    120                         bool userDefinedDefaultFunc = false; // user defined default ctor found
    121                         bool userDefinedCopyFunc = false; // user defined copy ctor found
    122                         std::list< DeclBall > decls;
    123 
    124                         // another FunctionDecl for the current type was found - determine
    125                         // if it has special properties and update data structure accordingly
    126                         ValueType & operator+=( FunctionDecl * function ) {
    127                                 bool isUserDefinedFunc = ! LinkageSpec::isOverridable( function->get_linkage() );
    128                                 bool isDefaultFunc = function->get_functionType()->get_parameters().size() == 1;
    129                                 bool isCopyFunc = InitTweak::isCopyConstructor( function );
    130                                 decls.push_back( DeclBall{ function, isUserDefinedFunc, isDefaultFunc, isCopyFunc } );
    131                                 userDefinedFunc = userDefinedFunc || isUserDefinedFunc;
    132                                 userDefinedDefaultFunc = userDefinedDefaultFunc || (isUserDefinedFunc && isDefaultFunc);
    133                                 userDefinedCopyFunc = userDefinedCopyFunc || (isUserDefinedFunc && isCopyFunc);
    134                                 return *this;
    135                         }
    136                 }; // ValueType
    137 
    138                 std::list< DeclarationWithType * > copy;
    139                 copy.splice( copy.end(), out );
    140 
    141                 // organize discovered declarations by type
    142                 std::unordered_map< std::string, ValueType > funcMap;
    143                 for ( DeclarationWithType * decl : copy ) {
    144                         if ( FunctionDecl * function = dynamic_cast< FunctionDecl * >( decl ) ) {
    145                                 std::list< DeclarationWithType * > params = function->get_functionType()->get_parameters();
    146                                 assert( ! params.empty() );
    147                                 funcMap[ Mangler::mangle( params.front()->get_type() ) ] += function;
    148                         } else {
    149                                 out.push_back( decl );
    150                         }
    151                 }
    152 
    153                 // if a type contains user defined ctor/dtors, then special rules trigger, which determine
    154                 // the set of ctor/dtors that are seen by the requester. In particular, if the user defines
    155                 // a default ctor, then the generated default ctor should never be seen, likewise for copy ctor
    156                 // and dtor. If the user defines any ctor/dtor, then no generated field ctors should be seen.
    157                 for ( std::pair< const std::string, ValueType > & pair : funcMap ) {
    158                         ValueType & val = pair.second;
    159                         for ( ValueType::DeclBall ball : val.decls ) {
    160                                 if ( ! val.userDefinedFunc || ball.isUserDefinedFunc || (! val.userDefinedDefaultFunc && ball.isDefaultFunc) || (! val.userDefinedCopyFunc && ball.isCopyFunc) ) {
    161                                         // decl conforms to the rules described above, so it should be seen by the requester
    162                                         out.push_back( ball.decl );
    163                                 }
    164                         }
    165                 }
    166         }
    167 
    168103        void Indexer::makeWritable() {
    169104                if ( ! tables ) {
     
    526461                        searchTables = searchTables->base.tables;
    527462                }
    528 
    529                 // some special functions, e.g. constructors and destructors
    530                 // remove autogenerated functions when they are defined so that
    531                 // they can never be matched
    532                 removeSpecialOverrides( id, out );
    533463        }
    534464
  • src/SymTab/Indexer.h

    r5fda7143 r1f75e2d  
    128128                static void deleteRef( Impl *toFree );
    129129
    130                 // Removes matching autogenerated constructors and destructors
    131                 // so that they will not be selected
    132                 // void removeSpecialOverrides( FunctionDecl *decl );
    133                 void removeSpecialOverrides( const std::string &id, std::list< DeclarationWithType * > & out ) const;
    134 
    135130                /// Ensures that tables variable is writable (i.e. allocated, uniquely owned by this Indexer, and at the current scope)
    136131                void makeWritable();
  • src/SynTree/Declaration.cc

    r5fda7143 r1f75e2d  
    5656}
    5757
    58 std::ostream & operator<<( std::ostream & out, const Declaration * decl ) {
     58std::ostream & operator<<( std::ostream & out, Declaration * decl ) {
    5959        decl->print( out );
    6060        return out;
  • src/SynTree/Declaration.h

    r5fda7143 r1f75e2d  
    279279};
    280280
    281 std::ostream & operator<<( std::ostream & out, const Declaration * decl );
     281std::ostream & operator<<( std::ostream & out, Declaration * decl );
    282282
    283283#endif // DECLARATION_H
  • src/SynTree/Expression.cc

    r5fda7143 r1f75e2d  
    358358        assert( member );
    359359        os << std::string( indent + 2, ' ' );
     360        os << (void*)member << " ";
    360361        member->print( os, indent + 2 );
    361362        os << std::endl;
     
    540541}
    541542
    542 std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
     543std::ostream & operator<<( std::ostream & out, Expression * expr ) {
    543544        expr->print( out );
    544545        return out;
  • src/SynTree/Expression.h

    r5fda7143 r1f75e2d  
    653653};
    654654
    655 std::ostream & operator<<( std::ostream & out, const Expression * expr );
     655std::ostream & operator<<( std::ostream & out, Expression * expr );
    656656
    657657#endif // EXPRESSION_H
  • src/SynTree/FunctionDecl.cc

    r5fda7143 r1f75e2d  
    2121#include "Attribute.h"
    2222#include "Common/utility.h"
    23 #include "InitTweak/InitTweak.h"
    2423
    2524FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, std::list< Attribute * > attributes )
  • src/SynTree/Statement.cc

    r5fda7143 r1f75e2d  
    387387}
    388388
    389 std::ostream & operator<<( std::ostream & out, const Statement * statement ) {
     389std::ostream & operator<<( std::ostream & out, Statement * statement ) {
    390390        statement->print( out );
    391391        return out;
  • src/SynTree/Statement.h

    r5fda7143 r1f75e2d  
    4747
    4848        std::list<Statement*>& get_kids() { return kids; }
    49         void push_back( Statement * stmt ) { kids.push_back( stmt ); }
    50         void push_front( Statement * stmt ) { kids.push_front( stmt ); }
    5149
    5250        virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); }
     
    397395
    398396
    399 std::ostream & operator<<( std::ostream & out, const Statement * statement );
     397std::ostream & operator<<( std::ostream & out, Statement * statement );
    400398
    401399#endif // STATEMENT_H
  • src/SynTree/Type.cc

    r5fda7143 r1f75e2d  
    8484}
    8585
    86 std::ostream & operator<<( std::ostream & out, const Type * type ) {
     86std::ostream & operator<<( std::ostream & out, Type * type ) {
    8787        type->print( out );
    8888        return out;
  • src/SynTree/Type.h

    r5fda7143 r1f75e2d  
    481481}
    482482
    483 std::ostream & operator<<( std::ostream & out, const Type * type );
     483std::ostream & operator<<( std::ostream & out, Type * type );
    484484
    485485#endif // TYPE_H
  • src/main.cc

    r5fda7143 r1f75e2d  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 29 17:34:39 2016
    13 // Update Count     : 426
     12// Last Modified On : Sat Aug 20 12:52:22 2016
     13// Update Count     : 403
    1414//
    1515
     
    7575static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
    7676
    77 void backtrace( int start ) {                                                   // skip first N stack frames
     77void sigSegvBusHandler( int sig_num ) {
    7878        enum { Frames = 50 };
    7979        void * array[Frames];
    8080        int size = backtrace( array, Frames );
     81
     82        cerr << "*CFA runtime error* program cfa-cpp terminated with "
     83                 <<     (sig_num == SIGSEGV ? "segment fault" : "bus error")
     84                 << " backtrace:" << endl;
     85
    8186        char ** messages = backtrace_symbols( array, size );
    8287
    83         // skip last 2 stack frames after main
    84         for ( int i = start; i < size - 2 && messages != nullptr; i += 1 ) {
     88        // skip first stack frame (points here)
     89        for ( int i = 2; i < size - 2 && messages != nullptr; i += 1 ) {
    8590                char * mangled_name = nullptr, * offset_begin = nullptr, * offset_end = nullptr;
    8691                for ( char *p = messages[i]; *p; ++p ) {        // find parantheses and +offset
     
    96101
    97102                // if line contains symbol, attempt to demangle
    98                 int frameNo = i - start;
    99103                if ( mangled_name && offset_begin && offset_end && mangled_name < offset_begin ) {
    100104                        *mangled_name++ = '\0';
     
    102106                        *offset_end++ = '\0';
    103107
    104                         int status, frameNo = i - start;
     108                        int status;
    105109                        char * real_name = __cxxabiv1::__cxa_demangle( mangled_name, 0, 0, &status );
    106110                        if ( status == 0 ) {                                            // demangling successful ?
    107                                 cerr << "(" << frameNo << ") " << messages[i] << " : "
     111                                cerr << "(" << i - 2 << ") " << messages[i] << " : "
    108112                                         << real_name << "+" << offset_begin << offset_end << endl;
    109113
    110114                        } else {                                                                        // otherwise, output mangled name
    111                                 cerr << "(" << frameNo << ") " << messages[i] << " : "
     115                                cerr << "(" << i - 2 << ") " << messages[i] << " : "
    112116                                         << mangled_name << "+" << offset_begin << offset_end << endl;
    113117                        } // if
    114118                        free( real_name );
    115119                } else {                                                                                // otherwise, print the whole line
    116                         cerr << "(" << frameNo << ") " << messages[i] << endl;
     120                        cerr << "(" << i - 2 << ") " << messages[i] << endl;
    117121                } // if
    118122        } // for
    119 
    120123        free( messages );
    121 } // backtrace
    122 
    123 void sigSegvBusHandler( int sig_num ) {
    124         cerr << "*CFA runtime error* program cfa-cpp terminated with "
    125                  <<     (sig_num == SIGSEGV ? "segment fault" : "bus error")
    126                  << " backtrace:" << endl;
    127         backtrace( 2 );                                                                         // skip first 2 stack frames
    128124        exit( EXIT_FAILURE );
    129125} // sigSegvBusHandler
    130 
    131 void sigAbortHandler( int sig_num ) {
    132         backtrace( 6 );                                                                         // skip first 6 stack frames
    133         signal( SIGABRT, SIG_DFL);                                                      // reset default signal handler
    134     raise( SIGABRT );                                                                   // reraise SIGABRT
    135 } // sigAbortHandler
    136 
    137126
    138127int main( int argc, char * argv[] ) {
     
    144133        signal( SIGSEGV, sigSegvBusHandler );
    145134        signal( SIGBUS, sigSegvBusHandler );
    146         signal( SIGABRT, sigAbortHandler );
    147135
    148136        parse_cmdline( argc, argv, filename );                          // process command-line arguments
  • src/tests/.expect/32/declarationSpecifier.txt

    r5fda7143 r1f75e2d  
    530530    return ((int )_retVal0);
    531531}
     532__attribute__ ((constructor(),)) static void _init_declarationSpecifier(void){
     533    ((void)___constructor__F_P13s__anonymous0_autogen___1(((struct __anonymous0 *)(&__x10__CV13s__anonymous0_1))));
     534    ((void)___constructor__F_P13s__anonymous1_autogen___1(((struct __anonymous1 *)(&__x11__CV13s__anonymous1_1))));
     535    ((void)___constructor__F_P13s__anonymous2_autogen___1(((struct __anonymous2 *)(&__x12__CV13s__anonymous2_1))));
     536    ((void)___constructor__F_P13s__anonymous3_autogen___1(((struct __anonymous3 *)(&__x13__CV13s__anonymous3_1))));
     537    ((void)___constructor__F_P13s__anonymous4_autogen___1(((struct __anonymous4 *)(&__x14__CV13s__anonymous4_1))));
     538    ((void)___constructor__F_P13s__anonymous5_autogen___1(((struct __anonymous5 *)(&__x15__CV13s__anonymous5_1))));
     539    ((void)___constructor__F_P13s__anonymous6_autogen___1(((struct __anonymous6 *)(&__x16__CV13s__anonymous6_1))));
     540    ((void)___constructor__F_P13s__anonymous7_autogen___1(((struct __anonymous7 *)(&__x17__CV13s__anonymous7_1))));
     541    ((void)___constructor__F_P13s__anonymous8_autogen___1(((struct __anonymous8 *)(&__x29__CV13s__anonymous8_1))));
     542    ((void)___constructor__F_P13s__anonymous9_autogen___1(((struct __anonymous9 *)(&__x30__CV13s__anonymous9_1))));
     543    ((void)___constructor__F_P14s__anonymous10_autogen___1(((struct __anonymous10 *)(&__x31__CV14s__anonymous10_1))));
     544    ((void)___constructor__F_P14s__anonymous11_autogen___1(((struct __anonymous11 *)(&__x32__CV14s__anonymous11_1))));
     545    ((void)___constructor__F_P14s__anonymous12_autogen___1(((struct __anonymous12 *)(&__x33__CV14s__anonymous12_1))));
     546    ((void)___constructor__F_P14s__anonymous13_autogen___1(((struct __anonymous13 *)(&__x34__CV14s__anonymous13_1))));
     547    ((void)___constructor__F_P14s__anonymous14_autogen___1(((struct __anonymous14 *)(&__x35__CV14s__anonymous14_1))));
     548    ((void)___constructor__F_P14s__anonymous15_autogen___1(((struct __anonymous15 *)(&__x36__CV14s__anonymous15_1))));
     549}
     550__attribute__ ((destructor(),)) static void _destroy_declarationSpecifier(void){
     551    ((void)___destructor__F_P14s__anonymous15_autogen___1(((struct __anonymous15 *)(&__x36__CV14s__anonymous15_1))));
     552    ((void)___destructor__F_P14s__anonymous14_autogen___1(((struct __anonymous14 *)(&__x35__CV14s__anonymous14_1))));
     553    ((void)___destructor__F_P14s__anonymous13_autogen___1(((struct __anonymous13 *)(&__x34__CV14s__anonymous13_1))));
     554    ((void)___destructor__F_P14s__anonymous12_autogen___1(((struct __anonymous12 *)(&__x33__CV14s__anonymous12_1))));
     555    ((void)___destructor__F_P14s__anonymous11_autogen___1(((struct __anonymous11 *)(&__x32__CV14s__anonymous11_1))));
     556    ((void)___destructor__F_P14s__anonymous10_autogen___1(((struct __anonymous10 *)(&__x31__CV14s__anonymous10_1))));
     557    ((void)___destructor__F_P13s__anonymous9_autogen___1(((struct __anonymous9 *)(&__x30__CV13s__anonymous9_1))));
     558    ((void)___destructor__F_P13s__anonymous8_autogen___1(((struct __anonymous8 *)(&__x29__CV13s__anonymous8_1))));
     559    ((void)___destructor__F_P13s__anonymous7_autogen___1(((struct __anonymous7 *)(&__x17__CV13s__anonymous7_1))));
     560    ((void)___destructor__F_P13s__anonymous6_autogen___1(((struct __anonymous6 *)(&__x16__CV13s__anonymous6_1))));
     561    ((void)___destructor__F_P13s__anonymous5_autogen___1(((struct __anonymous5 *)(&__x15__CV13s__anonymous5_1))));
     562    ((void)___destructor__F_P13s__anonymous4_autogen___1(((struct __anonymous4 *)(&__x14__CV13s__anonymous4_1))));
     563    ((void)___destructor__F_P13s__anonymous3_autogen___1(((struct __anonymous3 *)(&__x13__CV13s__anonymous3_1))));
     564    ((void)___destructor__F_P13s__anonymous2_autogen___1(((struct __anonymous2 *)(&__x12__CV13s__anonymous2_1))));
     565    ((void)___destructor__F_P13s__anonymous1_autogen___1(((struct __anonymous1 *)(&__x11__CV13s__anonymous1_1))));
     566    ((void)___destructor__F_P13s__anonymous0_autogen___1(((struct __anonymous0 *)(&__x10__CV13s__anonymous0_1))));
     567}
  • src/tests/.expect/32/extension.txt

    r5fda7143 r1f75e2d  
    8686        __extension__ int __c__i_2;
    8787    };
    88     int __i__i_2 = ((int )(__extension__ __a__i_1+__extension__ 3));
     88    int __i__i_2;
     89    ((void)((*((int *)(&__i__i_2)))=(__extension__ __a__i_1+__extension__ 3)) /* ?{} */);
    8990    ((void)__extension__ 3);
    9091    ((void)__extension__ __a__i_1);
  • src/tests/.expect/32/gccExtensions.txt

    r5fda7143 r1f75e2d  
    7676        ((void)((*((int *)(&(*___dst__P2sS_2).__c__i_2)))=__c__i_2) /* ?{} */);
    7777    }
    78     int __i__i_2 = ((int )__extension__ 3);
     78    int __i__i_2;
     79    ((void)((*((int *)(&__i__i_2)))=__extension__ 3) /* ?{} */);
    7980    __extension__ int __a__i_2;
    8081    __extension__ int __b__i_2;
     
    132133    }
    133134    struct s3 __x1__3ss3_2;
     135    ((void)___constructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    134136    struct s3 __y1__3ss3_2;
     137    ((void)___constructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
    135138    struct s4 {
    136139        int __i__i_2;
     
    138141    inline struct s4 ___operator_assign__F3ss4_P3ss43ss4_autogen___2(struct s4 *___dst__P3ss4_2, struct s4 ___src__3ss4_2){
    139142        ((void)((*___dst__P3ss4_2).__i__i_2=___src__3ss4_2.__i__i_2));
     143        ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
     144        ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    140145        return ((struct s4 )___src__3ss4_2);
    141146    }
     
    153158    }
    154159    struct s4 __x2__3ss4_2;
     160    ((void)___constructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));
    155161    struct s4 __y2__3ss4_2;
     162    ((void)___constructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));
    156163    int __m1__A0i_2[((unsigned int )10)];
    157164    int __m2__A0A0i_2[((unsigned int )10)][((unsigned int )10)];
     
    159166    int _retVal0 = { 0 };
    160167    ((void)(_retVal0=0) /* ?{} */);
     168    ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));
     169    ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));
     170    ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
     171    ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    161172    return ((int )_retVal0);
     173    ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));
     174    ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));
     175    ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
     176    ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    162177}
  • src/tests/.expect/64/declarationSpecifier.txt

    r5fda7143 r1f75e2d  
    530530    return ((int )_retVal0);
    531531}
     532__attribute__ ((constructor(),)) static void _init_declarationSpecifier(void){
     533    ((void)___constructor__F_P13s__anonymous0_autogen___1(((struct __anonymous0 *)(&__x10__CV13s__anonymous0_1))));
     534    ((void)___constructor__F_P13s__anonymous1_autogen___1(((struct __anonymous1 *)(&__x11__CV13s__anonymous1_1))));
     535    ((void)___constructor__F_P13s__anonymous2_autogen___1(((struct __anonymous2 *)(&__x12__CV13s__anonymous2_1))));
     536    ((void)___constructor__F_P13s__anonymous3_autogen___1(((struct __anonymous3 *)(&__x13__CV13s__anonymous3_1))));
     537    ((void)___constructor__F_P13s__anonymous4_autogen___1(((struct __anonymous4 *)(&__x14__CV13s__anonymous4_1))));
     538    ((void)___constructor__F_P13s__anonymous5_autogen___1(((struct __anonymous5 *)(&__x15__CV13s__anonymous5_1))));
     539    ((void)___constructor__F_P13s__anonymous6_autogen___1(((struct __anonymous6 *)(&__x16__CV13s__anonymous6_1))));
     540    ((void)___constructor__F_P13s__anonymous7_autogen___1(((struct __anonymous7 *)(&__x17__CV13s__anonymous7_1))));
     541    ((void)___constructor__F_P13s__anonymous8_autogen___1(((struct __anonymous8 *)(&__x29__CV13s__anonymous8_1))));
     542    ((void)___constructor__F_P13s__anonymous9_autogen___1(((struct __anonymous9 *)(&__x30__CV13s__anonymous9_1))));
     543    ((void)___constructor__F_P14s__anonymous10_autogen___1(((struct __anonymous10 *)(&__x31__CV14s__anonymous10_1))));
     544    ((void)___constructor__F_P14s__anonymous11_autogen___1(((struct __anonymous11 *)(&__x32__CV14s__anonymous11_1))));
     545    ((void)___constructor__F_P14s__anonymous12_autogen___1(((struct __anonymous12 *)(&__x33__CV14s__anonymous12_1))));
     546    ((void)___constructor__F_P14s__anonymous13_autogen___1(((struct __anonymous13 *)(&__x34__CV14s__anonymous13_1))));
     547    ((void)___constructor__F_P14s__anonymous14_autogen___1(((struct __anonymous14 *)(&__x35__CV14s__anonymous14_1))));
     548    ((void)___constructor__F_P14s__anonymous15_autogen___1(((struct __anonymous15 *)(&__x36__CV14s__anonymous15_1))));
     549}
     550__attribute__ ((destructor(),)) static void _destroy_declarationSpecifier(void){
     551    ((void)___destructor__F_P14s__anonymous15_autogen___1(((struct __anonymous15 *)(&__x36__CV14s__anonymous15_1))));
     552    ((void)___destructor__F_P14s__anonymous14_autogen___1(((struct __anonymous14 *)(&__x35__CV14s__anonymous14_1))));
     553    ((void)___destructor__F_P14s__anonymous13_autogen___1(((struct __anonymous13 *)(&__x34__CV14s__anonymous13_1))));
     554    ((void)___destructor__F_P14s__anonymous12_autogen___1(((struct __anonymous12 *)(&__x33__CV14s__anonymous12_1))));
     555    ((void)___destructor__F_P14s__anonymous11_autogen___1(((struct __anonymous11 *)(&__x32__CV14s__anonymous11_1))));
     556    ((void)___destructor__F_P14s__anonymous10_autogen___1(((struct __anonymous10 *)(&__x31__CV14s__anonymous10_1))));
     557    ((void)___destructor__F_P13s__anonymous9_autogen___1(((struct __anonymous9 *)(&__x30__CV13s__anonymous9_1))));
     558    ((void)___destructor__F_P13s__anonymous8_autogen___1(((struct __anonymous8 *)(&__x29__CV13s__anonymous8_1))));
     559    ((void)___destructor__F_P13s__anonymous7_autogen___1(((struct __anonymous7 *)(&__x17__CV13s__anonymous7_1))));
     560    ((void)___destructor__F_P13s__anonymous6_autogen___1(((struct __anonymous6 *)(&__x16__CV13s__anonymous6_1))));
     561    ((void)___destructor__F_P13s__anonymous5_autogen___1(((struct __anonymous5 *)(&__x15__CV13s__anonymous5_1))));
     562    ((void)___destructor__F_P13s__anonymous4_autogen___1(((struct __anonymous4 *)(&__x14__CV13s__anonymous4_1))));
     563    ((void)___destructor__F_P13s__anonymous3_autogen___1(((struct __anonymous3 *)(&__x13__CV13s__anonymous3_1))));
     564    ((void)___destructor__F_P13s__anonymous2_autogen___1(((struct __anonymous2 *)(&__x12__CV13s__anonymous2_1))));
     565    ((void)___destructor__F_P13s__anonymous1_autogen___1(((struct __anonymous1 *)(&__x11__CV13s__anonymous1_1))));
     566    ((void)___destructor__F_P13s__anonymous0_autogen___1(((struct __anonymous0 *)(&__x10__CV13s__anonymous0_1))));
     567}
  • src/tests/.expect/64/extension.txt

    r5fda7143 r1f75e2d  
    8686        __extension__ int __c__i_2;
    8787    };
    88     int __i__i_2 = ((int )(__extension__ __a__i_1+__extension__ 3));
     88    int __i__i_2;
     89    ((void)((*((int *)(&__i__i_2)))=(__extension__ __a__i_1+__extension__ 3)) /* ?{} */);
    8990    ((void)__extension__ 3);
    9091    ((void)__extension__ __a__i_1);
  • src/tests/.expect/64/gccExtensions.txt

    r5fda7143 r1f75e2d  
    7676        ((void)((*((int *)(&(*___dst__P2sS_2).__c__i_2)))=__c__i_2) /* ?{} */);
    7777    }
    78     int __i__i_2 = ((int )__extension__ 3);
     78    int __i__i_2;
     79    ((void)((*((int *)(&__i__i_2)))=__extension__ 3) /* ?{} */);
    7980    __extension__ int __a__i_2;
    8081    __extension__ int __b__i_2;
     
    132133    }
    133134    struct s3 __x1__3ss3_2;
     135    ((void)___constructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    134136    struct s3 __y1__3ss3_2;
     137    ((void)___constructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
    135138    struct s4 {
    136139        int __i__i_2;
     
    138141    inline struct s4 ___operator_assign__F3ss4_P3ss43ss4_autogen___2(struct s4 *___dst__P3ss4_2, struct s4 ___src__3ss4_2){
    139142        ((void)((*___dst__P3ss4_2).__i__i_2=___src__3ss4_2.__i__i_2));
     143        ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
     144        ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    140145        return ((struct s4 )___src__3ss4_2);
    141146    }
     
    153158    }
    154159    struct s4 __x2__3ss4_2;
     160    ((void)___constructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));
    155161    struct s4 __y2__3ss4_2;
     162    ((void)___constructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));
    156163    int __m1__A0i_2[((long unsigned int )10)];
    157164    int __m2__A0A0i_2[((long unsigned int )10)][((long unsigned int )10)];
     
    159166    int _retVal0 = { 0 };
    160167    ((void)(_retVal0=0) /* ?{} */);
     168    ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));
     169    ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));
     170    ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
     171    ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    161172    return ((int )_retVal0);
     173    ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));
     174    ((void)___destructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));
     175    ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
     176    ((void)___destructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    162177}
  • src/tests/Makefile.am

    r5fda7143 r1f75e2d  
    6262        ${CC} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
    6363
    64 memberCtors-ERR1: memberCtors.c
    65         ${CC} ${CFALGS} -DERR1 ${<} -o ${@}
     64ctorWarnings: ctorWarnings.c
     65        ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o /dev/null 2> ${@}
    6666
  • src/tests/Makefile.in

    r5fda7143 r1f75e2d  
    670670        ${CC} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
    671671
    672 memberCtors-ERR1: memberCtors.c
    673         ${CC} ${CFALGS} -DERR1 ${<} -o ${@}
     672ctorWarnings: ctorWarnings.c
     673        ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o /dev/null 2> ${@}
    674674
    675675# Tell versions [3.59,3.63) of GNU make to not export all variables.
  • src/tests/typeof.c

    r5fda7143 r1f75e2d  
    88    typeof( int ( int, int p ) ) *v7;
    99    typeof( [int] ( int, int p ) ) *v8;
    10     (typeof(v1)) v2; // cast with typeof
    1110}
Note: See TracChangeset for help on using the changeset viewer.