Changeset 3403534


Ignore:
Timestamp:
Sep 4, 2016, 10:34:35 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
f04a8b81
Parents:
28307be (diff), b16898e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

Location:
src
Files:
3 added
35 deleted
37 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.cc

    r28307be r3403534  
    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         errors.push_back( std::string( "Error: " ) + error );
     28  append( error );
    2929}
    3030
    3131void SemanticError::append( SemanticError &other ) {
    32         errors.splice( errors.end(), other.errors );
     32  errors.splice( errors.end(), other.errors );
     33}
     34
     35void SemanticError::append( const std::string & msg ) {
     36  errors.push_back( std::string( "Error: ") + msg );
    3337}
    3438
  • src/Common/SemanticError.h

    r28307be r3403534  
    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 & );
    3334        bool isEmpty() const;
    3435        void print( std::ostream &os );
     
    4243template< typename T >
    4344SemanticError::SemanticError( const std::string &error, const T *obj ) {
    44         std::ostringstream os;
    45         os << "Error: " << error;
    46         obj->print( os );
    47         errors.push_back( os.str() );
     45        append( toString( error, obj ) );
    4846}
     47
    4948
    5049#endif // SEMANTICERROR_H
  • src/Common/utility.h

    r28307be r3403534  
    246246}
    247247
     248// RAII object to regulate "save and restore" behaviour, e.g.
     249// void Foo::bar() {
     250//   ValueGuard<int> guard(var); // var is a member of type Foo
     251//   var = ...;
     252// } // var's original value is restored
     253template< typename T >
     254struct ValueGuard {
     255        T old;
     256        T& ref;
     257
     258        ValueGuard(T& inRef) : old(inRef), ref(inRef) {}
     259        ~ValueGuard() { ref = old; }
     260};
     261
     262template< typename T >
     263struct reverseIterate_t {
     264        T& ref;
     265
     266        reverseIterate_t( T & ref ) : ref(ref) {}
     267
     268        typedef typename T::reverse_iterator iterator;
     269        iterator begin() { return ref.rbegin(); }
     270        iterator end() { return ref.rend(); }
     271};
     272
     273template< typename T >
     274reverseIterate_t< T > reverseIterate( T & ref ) {
     275        return reverseIterate_t< T >( ref );
     276}
     277
    248278#endif // _UTILITY_H
    249279
  • src/GenPoly/Box.cc

    r28307be r3403534  
    158158                class PolyGenericCalculator : public PolyMutator {
    159159                public:
     160                        typedef PolyMutator Parent;
     161                        using Parent::mutate;
     162
    160163                        template< typename DeclClass >
    161164                        DeclClass *handleDecl( DeclClass *decl, Type *type );
     
    16751678                DeclClass * PolyGenericCalculator::handleDecl( DeclClass *decl, Type *type ) {
    16761679                        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();
     1687                        endTypeScope();
     1688                        return ret;
     1689                }
     1690
     1691                ObjectDecl * PolyGenericCalculator::mutate( ObjectDecl *objectDecl ) {
     1692                        return handleDecl( objectDecl, objectDecl->get_type() );
     1693                }
     1694
     1695                DeclarationWithType * PolyGenericCalculator::mutate( FunctionDecl *functionDecl ) {
    16771696                        knownLayouts.beginScope();
    16781697                        knownOffsets.beginScope();
    16791698
    1680                         DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) );
    1681 
     1699                        DeclarationWithType * decl = handleDecl( functionDecl, functionDecl->get_functionType() );
    16821700                        knownOffsets.endScope();
    16831701                        knownLayouts.endScope();
    1684                         endTypeScope();
    1685                         return ret;
    1686                 }
    1687 
    1688                 ObjectDecl * PolyGenericCalculator::mutate( ObjectDecl *objectDecl ) {
    1689                         return handleDecl( objectDecl, objectDecl->get_type() );
    1690                 }
    1691 
    1692                 DeclarationWithType * PolyGenericCalculator::mutate( FunctionDecl *functionDecl ) {
    1693                         return handleDecl( functionDecl, functionDecl->get_functionType() );
     1702                        return decl;
    16941703                }
    16951704
     
    17001709                TypeDecl * PolyGenericCalculator::mutate( TypeDecl *typeDecl ) {
    17011710                        scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
    1702                         return Mutator::mutate( typeDecl );
     1711                        return Parent::mutate( typeDecl );
    17031712                }
    17041713
     
    17061715                        beginTypeScope( pointerType );
    17071716
    1708                         Type *ret = Mutator::mutate( pointerType );
     1717                        Type *ret = Parent::mutate( pointerType );
    17091718
    17101719                        endTypeScope();
     
    17241733                        }
    17251734
    1726                         Type *ret = Mutator::mutate( funcType );
     1735                        Type *ret = Parent::mutate( funcType );
    17271736
    17281737                        endTypeScope();
     
    17451754                                }
    17461755                        }
    1747                         return Mutator::mutate( declStmt );
     1756                        return Parent::mutate( declStmt );
    17481757                }
    17491758
     
    17871796                Expression *PolyGenericCalculator::mutate( MemberExpr *memberExpr ) {
    17881797                        // mutate, exiting early if no longer MemberExpr
    1789                         Expression *expr = Mutator::mutate( memberExpr );
     1798                        Expression *expr = Parent::mutate( memberExpr );
    17901799                        memberExpr = dynamic_cast< MemberExpr* >( expr );
    17911800                        if ( ! memberExpr ) return expr;
     
    19721981                Expression *PolyGenericCalculator::mutate( OffsetofExpr *offsetofExpr ) {
    19731982                        // mutate, exiting early if no longer OffsetofExpr
    1974                         Expression *expr = Mutator::mutate( offsetofExpr );
     1983                        Expression *expr = Parent::mutate( offsetofExpr );
    19751984                        offsetofExpr = dynamic_cast< OffsetofExpr* >( expr );
    19761985                        if ( ! offsetofExpr ) return expr;
  • src/GenPoly/PolyMutator.h

    r28307be r3403534  
    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
    3235                PolyMutator();
    3336
     
    4245                virtual Statement* mutate(ExprStmt *catchStmt);
    4346                virtual Statement* mutate(ReturnStmt *catchStmt);
    44  
     47
    4548                virtual Expression* mutate(UntypedExpr *untypedExpr);
    4649
     
    5457                Statement* mutateStatement( Statement *stmt );
    5558                Expression* mutateExpression( Expression *expr );
    56  
     59
    5760                TyVarMap scopeTyVars;
    5861                TypeSubstitution *env;
     
    6063                std::list< Statement* > stmtsToAddAfter;
    6164        };
    62 } // namespace 
     65} // namespace
    6366
    6467#endif // _POLYMUTATOR_H
  • src/InitTweak/FixInit.cc

    r28307be r3403534  
    3131#include "SynTree/Mutator.h"
    3232#include "SymTab/Indexer.h"
     33#include "SymTab/Autogen.h"
    3334#include "GenPoly/PolyMutator.h"
    3435#include "SynTree/AddStmtVisitor.h"
     
    176177                };
    177178
    178                 class WarnStructMembers : public Visitor {
     179                class GenStructMemberCalls : public SymTab::Indexer {
    179180                  public:
    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 );
     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 );
    184186
    185187                        virtual void visit( FunctionDecl * funcDecl );
     
    188190                        virtual void visit( ApplicationExpr * appExpr );
    189191
     192                        SemanticError errors;
    190193                  private:
    191194                        void handleFirstParam( Expression * firstParam );
     195                        template< typename... Params >
     196                        void emit( const Params &... params );
    192197
    193198                        FunctionDecl * function = 0;
    194                         std::set< DeclarationWithType * > unhandled;
     199                        std::set< DeclarationWithType * > unhandled, usedUninit;
    195200                        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;
    196217                };
    197218        } // namespace
     
    209230                FixCopyCtors::fixCopyCtors( translationUnit );
    210231
    211                 WarnStructMembers::warnings( translationUnit );
     232                GenStructMemberCalls::generate( translationUnit );
    212233        }
    213234
     
    254275                }
    255276
    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 );
     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;
    260284                        }
    261285                }
     
    528552                                                        FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false );
    529553                                                        dtorCaller->fixUniqueId();
    530                                                         dtorCaller->get_statements()->get_kids().push_back( dtorStmt );
     554                                                        dtorCaller->get_statements()->push_back( dtorStmt );
    531555
    532556                                                        // atexit(dtor_atexit);
     
    543567                                                        // at global scope and there could be multiple function-scoped
    544568                                                        // 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.
    545574                                                        static UniqueName staticNamer( "_static_var" );
    546                                                         objDecl->set_mangleName( objDecl->get_mangleName() + staticNamer.newName() );
     575                                                        objDecl->set_name( objDecl->get_name() + staticNamer.newName() );
     576                                                        objDecl->set_mangleName( SymTab::Mangler::mangle( objDecl ) );
    547577
    548578                                                        objDecl->set_init( NULL );
     
    709739                }
    710740
    711                 void WarnStructMembers::visit( FunctionDecl * funcDecl ) {
    712                         WarnStructMembers old = *this;
    713                         *this = WarnStructMembers();
     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();
    714752
    715753                        function = funcDecl;
    716                         if ( checkWarnings( funcDecl ) ) {
    717                                 FunctionType * type = funcDecl->get_functionType();
     754                        isCtor = isConstructor( function->get_name() );
     755                        if ( checkWarnings( function ) ) {
     756                                FunctionType * type = function->get_functionType();
    718757                                assert( ! type->get_parameters().empty() );
    719758                                thisParam = safe_dynamic_cast< ObjectDecl * >( type->get_parameters().front() );
     
    721760                                StructInstType * structType = dynamic_cast< StructInstType * >( ptrType->get_base() );
    722761                                if ( structType ) {
    723                                         StructDecl * structDecl = structType->get_baseStruct();
     762                                        structDecl = structType->get_baseStruct();
    724763                                        for ( Declaration * member : structDecl->get_members() ) {
    725764                                                if ( ObjectDecl * field = dynamic_cast< ObjectDecl * >( member ) ) {
     
    731770                                }
    732771                        }
    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" );
     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" );
    738780                        }
    739781
    740                         *this = old;
    741                 }
    742 
    743                 void WarnStructMembers::visit( ApplicationExpr * appExpr ) {
     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 ) {
    744834                        if ( ! checkWarnings( function ) ) return;
    745835
     
    760850                                        handleFirstParam( firstParam );
    761851                                }
    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() );
    767852                        }
    768853
     
    770855                }
    771856
    772                 void WarnStructMembers::handleFirstParam( Expression * firstParam ) {
     857                void GenStructMemberCalls::handleFirstParam( Expression * firstParam ) {
    773858                        using namespace std;
    774859                        if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( firstParam ) ) {
     
    787872                }
    788873
    789                 void WarnStructMembers::visit( MemberExpr * memberExpr ) {
     874                void GenStructMemberCalls::visit( MemberExpr * memberExpr ) {
    790875                        if ( ! checkWarnings( function ) ) return;
    791                         if ( ! isConstructor( function->get_name() ) ) return;
     876                        if ( ! isCtor ) return;
    792877
    793878                        if ( ApplicationExpr * deref = dynamic_cast< ApplicationExpr * >( memberExpr->get_aggregate() ) ) {
     
    797882                                                        if ( unhandled.count( memberExpr->get_member() ) ) {
    798883                                                                // emit a warning because a member was used before it was constructed
    799                                                                 warn( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", memberExpr->get_member()->get_name(), " used before being constructed" );
     884                                                                usedUninit.insert( memberExpr->get_member() );
    800885                                                        }
    801886                                                }
     
    805890                        Parent::visit( memberExpr );
    806891                }
     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                }
    807916        } // namespace
    808917} // namespace InitTweak
  • src/InitTweak/GenInit.cc

    r28307be r3403534  
    2525#include "SynTree/Mutator.h"
    2626#include "SymTab/Autogen.h"
     27#include "SymTab/Mangler.h"
    2728#include "GenPoly/PolyMutator.h"
    2829#include "GenPoly/DeclMutator.h"
     30#include "GenPoly/ScopedSet.h"
    2931
    3032namespace InitTweak {
     
    5557        class CtorDtor : public GenPoly::PolyMutator {
    5658          public:
     59                typedef GenPoly::PolyMutator Parent;
     60                using Parent::mutate;
    5761                /// create constructor and destructor statements for object declarations.
    5862                /// the actual call statements will be added in after the resolver has run
     
    6569                // should not traverse into any of these declarations to find objects
    6670                // that need to be constructed or destructed
    67                 virtual Declaration* mutate( StructDecl *aggregateDecl ) { return aggregateDecl; }
     71                virtual Declaration* mutate( StructDecl *aggregateDecl );
    6872                virtual Declaration* mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; }
    6973                virtual Declaration* mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; }
     
    7478                virtual Type * mutate( FunctionType *funcType ) { return funcType; }
    7579
    76           protected:
     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;
    7791        };
    7892
     
    142156
    143157        DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) {
    144                 std::list<DeclarationWithType*> oldReturnVals = returnVals;
    145                 std::string oldFuncName = funcName;
     158                ValueGuard< std::list<DeclarationWithType*> > oldReturnVals( returnVals );
     159                ValueGuard< std::string > oldFuncName( funcName );
    146160
    147161                FunctionType * type = functionDecl->get_functionType();
     
    149163                funcName = functionDecl->get_name();
    150164                DeclarationWithType * decl = Mutator::mutate( functionDecl );
    151                 returnVals = oldReturnVals;
    152                 funcName = oldFuncName;
    153165                return decl;
    154166        }
     
    197209
    198210        DeclarationWithType * HoistArrayDimension::mutate( FunctionDecl *functionDecl ) {
    199                 bool oldInFunc = inFunction;
     211                ValueGuard< bool > oldInFunc( inFunction );
    200212                inFunction = true;
    201213                DeclarationWithType * decl = Parent::mutate( functionDecl );
    202                 inFunction = oldInFunc;
    203214                return decl;
    204215        }
     
    209220        }
    210221
     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
    211240        DeclarationWithType * CtorDtor::mutate( ObjectDecl * objDecl ) {
    212                 // hands off if designated, if @=, or if extern
    213                 if ( tryConstruct( 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                        // xxx - constructed objects should not have initializers nested too deeply
     248
    214249                        // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor
    215250                        // for each constructable object
     
    241276                        }
    242277                }
    243                 return Mutator::mutate( objDecl );
     278                return Parent::mutate( objDecl );
    244279        }
    245280
    246281        DeclarationWithType * CtorDtor::mutate( FunctionDecl *functionDecl ) {
     282                ValueGuard< bool > oldInFunc = inFunction;
     283                inFunction = true;
     284
     285                handleDWT( functionDecl );
     286
     287                managedTypes.beginScope();
     288                // go through assertions and recursively add seen ctor/dtors
     289                for ( TypeDecl * tyDecl : functionDecl->get_functionType()->get_forall() ) {
     290                        for ( DeclarationWithType *& assertion : tyDecl->get_assertions() ) {
     291                                assertion = assertion->acceptMutator( *this );
     292                        }
     293                }
    247294                // parameters should not be constructed and destructed, so don't mutate FunctionType
    248295                mutateAll( functionDecl->get_oldDecls(), *this );
    249296                functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
     297
     298                managedTypes.endScope();
    250299                return functionDecl;
    251300        }
     301
     302        Declaration* CtorDtor::mutate( StructDecl *aggregateDecl ) {
     303                // don't construct members, but need to take note if there is a managed member,
     304                // because that means that this type is also managed
     305                for ( Declaration * member : aggregateDecl->get_members() ) {
     306                        if ( ObjectDecl * field = dynamic_cast< ObjectDecl * >( member ) ) {
     307                                if ( isManaged( field ) ) {
     308                                        managedTypes.insert( SymTab::Mangler::mangle( aggregateDecl ) );
     309                                        break;
     310                                }
     311                        }
     312                }
     313                return aggregateDecl;
     314        }
     315
     316        CompoundStmt * CtorDtor::mutate( CompoundStmt * compoundStmt ) {
     317                managedTypes.beginScope();
     318                CompoundStmt * stmt = Parent::mutate( compoundStmt );
     319                managedTypes.endScope();
     320                return stmt;
     321        }
     322
    252323} // namespace InitTweak
    253324
  • src/InitTweak/InitTweak.cc

    r28307be r3403534  
    77#include "SynTree/Attribute.h"
    88#include "GenPoly/GenPoly.h"
     9#include "ResolvExpr/typeops.h"
    910
    1011namespace InitTweak {
     
    7980        public:
    8081                ExprImpl( Expression * expr ) : arg( expr ) {}
     82
     83                ~ExprImpl() { delete arg; }
    8184
    8285                virtual std::list< Expression * > next( std::list< Expression * > & indices ) {
     
    122125
    123126        void InitExpander::clearArrayIndices() {
     127                deleteAll( indices );
    124128                indices.clear();
    125129        }
     
    228232                return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) &&
    229233                        (objDecl->get_init() == NULL ||
    230                                 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )) &&
    231                         ! isDesignated( objDecl->get_init() )
     234                                ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() ))
    232235                        && objDecl->get_storageClass() != DeclarationNode::Extern;
    233236        }
     
    387390                virtual void visit( ApplicationExpr *applicationExpr ) { isConstExpr = false; }
    388391                virtual void visit( UntypedExpr *untypedExpr ) { isConstExpr = false; }
    389                 virtual void visit( NameExpr *nameExpr ) { isConstExpr = false; }
    390                 virtual void visit( CastExpr *castExpr ) { isConstExpr = false; }
     392                virtual void visit( NameExpr *nameExpr ) {
     393                        // xxx - temporary hack, because 0 and 1 really should be constexprs, even though they technically aren't in Cforall today
     394                        if ( nameExpr->get_name() != "0" && nameExpr->get_name() != "1" ) isConstExpr = false;
     395                }
     396                // virtual void visit( CastExpr *castExpr ) { isConstExpr = false; }
     397                virtual void visit( AddressExpr *addressExpr ) {
     398                        // address of a variable or member expression is constexpr
     399                        Expression * arg = addressExpr->get_arg();
     400                        if ( ! dynamic_cast< NameExpr * >( arg) && ! dynamic_cast< VariableExpr * >( arg ) && ! dynamic_cast< MemberExpr * >( arg ) && ! dynamic_cast< UntypedMemberExpr * >( arg ) ) isConstExpr = false;
     401                }
    391402                virtual void visit( LabelAddressExpr *labAddressExpr ) { isConstExpr = false; }
    392403                virtual void visit( UntypedMemberExpr *memberExpr ) { isConstExpr = false; }
    393404                virtual void visit( MemberExpr *memberExpr ) { isConstExpr = false; }
    394405                virtual void visit( VariableExpr *variableExpr ) { isConstExpr = false; }
    395                 virtual void visit( ConstantExpr *constantExpr ) { /* bottom out */ }
    396406                // these might be okay?
    397407                // virtual void visit( SizeofExpr *sizeofExpr );
     
    436446        bool isDestructor( const std::string & str ) { return str == "^?{}"; }
    437447        bool isCtorDtor( const std::string & str ) { return isConstructor( str ) || isDestructor( str ); }
     448
     449        FunctionDecl * isCopyConstructor( Declaration * decl ) {
     450                FunctionDecl * function = dynamic_cast< FunctionDecl * >( decl );
     451                if ( ! function ) return 0;
     452                if ( ! isConstructor( function->get_name() ) ) return 0;
     453                FunctionType * ftype = function->get_functionType();
     454                if ( ftype->get_parameters().size() != 2 ) return 0;
     455
     456                Type * t1 = ftype->get_parameters().front()->get_type();
     457                Type * t2 = ftype->get_parameters().back()->get_type();
     458                PointerType * ptrType = dynamic_cast< PointerType * > ( t1 );
     459                assert( ptrType );
     460
     461                if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) {
     462                        return function;
     463                } else {
     464                        return 0;
     465                }
     466        }
    438467}
  • src/InitTweak/InitTweak.h

    r28307be r3403534  
    2929        bool isDestructor( const std::string & );
    3030        bool isCtorDtor( const std::string & );
     31
     32        FunctionDecl * isCopyConstructor( Declaration * decl );
    3133
    3234        /// transform Initializer into an argument list that can be passed to a call expression
  • src/Makefile.am

    r28307be r3403534  
    2525# Is there a way to use a variable for the directory names?
    2626
    27 include ArgTweak/module.mk
    2827include CodeGen/module.mk
    2928include Common/module.mk
    3029include ControlStruct/module.mk
    31 include Designators/module.mk
    3230include GenPoly/module.mk
    3331include InitTweak/module.mk
  • src/Makefile.in

    r28307be r3403534  
    2222###############################################################################
    2323
    24 ######################### -*- Mode: Makefile-Gmake -*- ########################
    25 ###############################################################################
    26 
    2724#SRC +=  ArgTweak/Rewriter.cc \
    2825#       ArgTweak/Mutate.cc
    29 
    30 ######################### -*- Mode: Makefile-Gmake -*- ########################
    31 ###############################################################################
    3226
    3327######################### -*- Mode: Makefile-Gmake -*- ########################
     
    7569PRE_UNINSTALL = :
    7670POST_UNINSTALL = :
    77 DIST_COMMON = $(srcdir)/ArgTweak/module.mk $(srcdir)/CodeGen/module.mk \
    78         $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk \
    79         $(srcdir)/Designators/module.mk $(srcdir)/GenPoly/module.mk \
     71DIST_COMMON = $(srcdir)/CodeGen/module.mk $(srcdir)/Common/module.mk \
     72        $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk \
    8073        $(srcdir)/InitTweak/module.mk $(srcdir)/Makefile.am \
    8174        $(srcdir)/Makefile.in $(srcdir)/Parser/module.mk \
     
    112105        ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \
    113106        ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT) \
    114         Designators/driver_cfa_cpp-Processor.$(OBJEXT) \
    115107        GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \
    116108        GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \
     
    196188        SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \
    197189        SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \
    198         Tuples/driver_cfa_cpp-Mutate.$(OBJEXT) \
    199         Tuples/driver_cfa_cpp-AssignExpand.$(OBJEXT) \
    200         Tuples/driver_cfa_cpp-FunctionFixer.$(OBJEXT) \
    201190        Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \
    202         Tuples/driver_cfa_cpp-FunctionChecker.$(OBJEXT) \
    203191        Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)
    204192am_driver_cfa_cpp_OBJECTS = $(am__objects_1)
     
    374362        ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \
    375363        ControlStruct/ForExprMutator.cc \
    376         ControlStruct/LabelTypeChecker.cc Designators/Processor.cc \
    377         GenPoly/Box.cc GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \
     364        ControlStruct/LabelTypeChecker.cc GenPoly/Box.cc \
     365        GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \
    378366        GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \
    379367        GenPoly/CopyParams.cc GenPoly/FindFunction.cc \
     
    413401        SynTree/Initializer.cc SynTree/Visitor.cc SynTree/Mutator.cc \
    414402        SynTree/AddStmtVisitor.cc SynTree/TypeSubstitution.cc \
    415         SynTree/Attribute.cc Tuples/Mutate.cc Tuples/AssignExpand.cc \
    416         Tuples/FunctionFixer.cc Tuples/TupleAssignment.cc \
    417         Tuples/FunctionChecker.cc Tuples/NameMatcher.cc
     403        SynTree/Attribute.cc Tuples/TupleAssignment.cc \
     404        Tuples/NameMatcher.cc
    418405MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    419406        ${cfa_cpplib_PROGRAMS}}
     
    433420.SUFFIXES:
    434421.SUFFIXES: .cc .ll .o .obj .yy
    435 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/ArgTweak/module.mk $(srcdir)/CodeGen/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/Designators/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(am__configure_deps)
     422$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/CodeGen/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk $(am__configure_deps)
    436423        @for dep in $?; do \
    437424          case '$(am__configure_deps)' in \
     
    454441            cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
    455442        esac;
    456 $(srcdir)/ArgTweak/module.mk $(srcdir)/CodeGen/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/Designators/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk:
     443$(srcdir)/CodeGen/module.mk $(srcdir)/Common/module.mk $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk $(srcdir)/InitTweak/module.mk $(srcdir)/Parser/module.mk $(srcdir)/ResolvExpr/module.mk $(srcdir)/SymTab/module.mk $(srcdir)/SynTree/module.mk $(srcdir)/Tuples/module.mk:
    457444
    458445$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
     
    553540        ControlStruct/$(am__dirstamp) \
    554541        ControlStruct/$(DEPDIR)/$(am__dirstamp)
    555 Designators/$(am__dirstamp):
    556         @$(MKDIR_P) Designators
    557         @: > Designators/$(am__dirstamp)
    558 Designators/$(DEPDIR)/$(am__dirstamp):
    559         @$(MKDIR_P) Designators/$(DEPDIR)
    560         @: > Designators/$(DEPDIR)/$(am__dirstamp)
    561 Designators/driver_cfa_cpp-Processor.$(OBJEXT):  \
    562         Designators/$(am__dirstamp) \
    563         Designators/$(DEPDIR)/$(am__dirstamp)
    564542GenPoly/$(am__dirstamp):
    565543        @$(MKDIR_P) GenPoly
     
    789767        @$(MKDIR_P) Tuples/$(DEPDIR)
    790768        @: > Tuples/$(DEPDIR)/$(am__dirstamp)
    791 Tuples/driver_cfa_cpp-Mutate.$(OBJEXT): Tuples/$(am__dirstamp) \
    792         Tuples/$(DEPDIR)/$(am__dirstamp)
    793 Tuples/driver_cfa_cpp-AssignExpand.$(OBJEXT): Tuples/$(am__dirstamp) \
    794         Tuples/$(DEPDIR)/$(am__dirstamp)
    795 Tuples/driver_cfa_cpp-FunctionFixer.$(OBJEXT): Tuples/$(am__dirstamp) \
    796         Tuples/$(DEPDIR)/$(am__dirstamp)
    797769Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT):  \
    798         Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp)
    799 Tuples/driver_cfa_cpp-FunctionChecker.$(OBJEXT):  \
    800770        Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp)
    801771Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT): Tuples/$(am__dirstamp) \
     
    824794        -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT)
    825795        -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT)
    826         -rm -f Designators/driver_cfa_cpp-Processor.$(OBJEXT)
    827796        -rm -f GenPoly/driver_cfa_cpp-Box.$(OBJEXT)
    828797        -rm -f GenPoly/driver_cfa_cpp-CopyParams.$(OBJEXT)
     
    908877        -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT)
    909878        -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT)
    910         -rm -f Tuples/driver_cfa_cpp-AssignExpand.$(OBJEXT)
    911         -rm -f Tuples/driver_cfa_cpp-FunctionChecker.$(OBJEXT)
    912         -rm -f Tuples/driver_cfa_cpp-FunctionFixer.$(OBJEXT)
    913         -rm -f Tuples/driver_cfa_cpp-Mutate.$(OBJEXT)
    914879        -rm -f Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)
    915880        -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT)
     
    934899@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@
    935900@AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@
    936 @AMDEP_TRUE@@am__include@ @am__quote@Designators/$(DEPDIR)/driver_cfa_cpp-Processor.Po@am__quote@
    937901@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-Box.Po@am__quote@
    938902@AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-CopyParams.Po@am__quote@
     
    1018982@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@
    1019983@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@
    1020 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-AssignExpand.Po@am__quote@
    1021 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionChecker.Po@am__quote@
    1022 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionFixer.Po@am__quote@
    1023 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@
    1024984@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po@am__quote@
    1025985@AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@
     
    12651225@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi`
    12661226
    1267 Designators/driver_cfa_cpp-Processor.o: Designators/Processor.cc
    1268 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Designators/driver_cfa_cpp-Processor.o -MD -MP -MF Designators/$(DEPDIR)/driver_cfa_cpp-Processor.Tpo -c -o Designators/driver_cfa_cpp-Processor.o `test -f 'Designators/Processor.cc' || echo '$(srcdir)/'`Designators/Processor.cc
    1269 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Designators/$(DEPDIR)/driver_cfa_cpp-Processor.Tpo Designators/$(DEPDIR)/driver_cfa_cpp-Processor.Po
    1270 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Designators/Processor.cc' object='Designators/driver_cfa_cpp-Processor.o' libtool=no @AMDEPBACKSLASH@
    1271 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1272 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Designators/driver_cfa_cpp-Processor.o `test -f 'Designators/Processor.cc' || echo '$(srcdir)/'`Designators/Processor.cc
    1273 
    1274 Designators/driver_cfa_cpp-Processor.obj: Designators/Processor.cc
    1275 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Designators/driver_cfa_cpp-Processor.obj -MD -MP -MF Designators/$(DEPDIR)/driver_cfa_cpp-Processor.Tpo -c -o Designators/driver_cfa_cpp-Processor.obj `if test -f 'Designators/Processor.cc'; then $(CYGPATH_W) 'Designators/Processor.cc'; else $(CYGPATH_W) '$(srcdir)/Designators/Processor.cc'; fi`
    1276 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Designators/$(DEPDIR)/driver_cfa_cpp-Processor.Tpo Designators/$(DEPDIR)/driver_cfa_cpp-Processor.Po
    1277 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Designators/Processor.cc' object='Designators/driver_cfa_cpp-Processor.obj' libtool=no @AMDEPBACKSLASH@
    1278 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    1279 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Designators/driver_cfa_cpp-Processor.obj `if test -f 'Designators/Processor.cc'; then $(CYGPATH_W) 'Designators/Processor.cc'; else $(CYGPATH_W) '$(srcdir)/Designators/Processor.cc'; fi`
    1280 
    12811227GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc
    12821228@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT GenPoly/driver_cfa_cpp-Box.o -MD -MP -MF GenPoly/$(DEPDIR)/driver_cfa_cpp-Box.Tpo -c -o GenPoly/driver_cfa_cpp-Box.o `test -f 'GenPoly/Box.cc' || echo '$(srcdir)/'`GenPoly/Box.cc
     
    24412387@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Attribute.obj `if test -f 'SynTree/Attribute.cc'; then $(CYGPATH_W) 'SynTree/Attribute.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Attribute.cc'; fi`
    24422388
    2443 Tuples/driver_cfa_cpp-Mutate.o: Tuples/Mutate.cc
    2444 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-Mutate.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-Mutate.Tpo -c -o Tuples/driver_cfa_cpp-Mutate.o `test -f 'Tuples/Mutate.cc' || echo '$(srcdir)/'`Tuples/Mutate.cc
    2445 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-Mutate.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-Mutate.Po
    2446 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/Mutate.cc' object='Tuples/driver_cfa_cpp-Mutate.o' libtool=no @AMDEPBACKSLASH@
    2447 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2448 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-Mutate.o `test -f 'Tuples/Mutate.cc' || echo '$(srcdir)/'`Tuples/Mutate.cc
    2449 
    2450 Tuples/driver_cfa_cpp-Mutate.obj: Tuples/Mutate.cc
    2451 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-Mutate.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-Mutate.Tpo -c -o Tuples/driver_cfa_cpp-Mutate.obj `if test -f 'Tuples/Mutate.cc'; then $(CYGPATH_W) 'Tuples/Mutate.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/Mutate.cc'; fi`
    2452 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-Mutate.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-Mutate.Po
    2453 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/Mutate.cc' object='Tuples/driver_cfa_cpp-Mutate.obj' libtool=no @AMDEPBACKSLASH@
    2454 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2455 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-Mutate.obj `if test -f 'Tuples/Mutate.cc'; then $(CYGPATH_W) 'Tuples/Mutate.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/Mutate.cc'; fi`
    2456 
    2457 Tuples/driver_cfa_cpp-AssignExpand.o: Tuples/AssignExpand.cc
    2458 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-AssignExpand.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-AssignExpand.Tpo -c -o Tuples/driver_cfa_cpp-AssignExpand.o `test -f 'Tuples/AssignExpand.cc' || echo '$(srcdir)/'`Tuples/AssignExpand.cc
    2459 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-AssignExpand.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-AssignExpand.Po
    2460 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/AssignExpand.cc' object='Tuples/driver_cfa_cpp-AssignExpand.o' libtool=no @AMDEPBACKSLASH@
    2461 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2462 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-AssignExpand.o `test -f 'Tuples/AssignExpand.cc' || echo '$(srcdir)/'`Tuples/AssignExpand.cc
    2463 
    2464 Tuples/driver_cfa_cpp-AssignExpand.obj: Tuples/AssignExpand.cc
    2465 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-AssignExpand.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-AssignExpand.Tpo -c -o Tuples/driver_cfa_cpp-AssignExpand.obj `if test -f 'Tuples/AssignExpand.cc'; then $(CYGPATH_W) 'Tuples/AssignExpand.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/AssignExpand.cc'; fi`
    2466 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-AssignExpand.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-AssignExpand.Po
    2467 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/AssignExpand.cc' object='Tuples/driver_cfa_cpp-AssignExpand.obj' libtool=no @AMDEPBACKSLASH@
    2468 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2469 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-AssignExpand.obj `if test -f 'Tuples/AssignExpand.cc'; then $(CYGPATH_W) 'Tuples/AssignExpand.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/AssignExpand.cc'; fi`
    2470 
    2471 Tuples/driver_cfa_cpp-FunctionFixer.o: Tuples/FunctionFixer.cc
    2472 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-FunctionFixer.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionFixer.Tpo -c -o Tuples/driver_cfa_cpp-FunctionFixer.o `test -f 'Tuples/FunctionFixer.cc' || echo '$(srcdir)/'`Tuples/FunctionFixer.cc
    2473 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionFixer.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionFixer.Po
    2474 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/FunctionFixer.cc' object='Tuples/driver_cfa_cpp-FunctionFixer.o' libtool=no @AMDEPBACKSLASH@
    2475 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2476 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-FunctionFixer.o `test -f 'Tuples/FunctionFixer.cc' || echo '$(srcdir)/'`Tuples/FunctionFixer.cc
    2477 
    2478 Tuples/driver_cfa_cpp-FunctionFixer.obj: Tuples/FunctionFixer.cc
    2479 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-FunctionFixer.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionFixer.Tpo -c -o Tuples/driver_cfa_cpp-FunctionFixer.obj `if test -f 'Tuples/FunctionFixer.cc'; then $(CYGPATH_W) 'Tuples/FunctionFixer.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/FunctionFixer.cc'; fi`
    2480 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionFixer.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionFixer.Po
    2481 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/FunctionFixer.cc' object='Tuples/driver_cfa_cpp-FunctionFixer.obj' libtool=no @AMDEPBACKSLASH@
    2482 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2483 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-FunctionFixer.obj `if test -f 'Tuples/FunctionFixer.cc'; then $(CYGPATH_W) 'Tuples/FunctionFixer.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/FunctionFixer.cc'; fi`
    2484 
    24852389Tuples/driver_cfa_cpp-TupleAssignment.o: Tuples/TupleAssignment.cc
    24862390@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-TupleAssignment.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Tpo -c -o Tuples/driver_cfa_cpp-TupleAssignment.o `test -f 'Tuples/TupleAssignment.cc' || echo '$(srcdir)/'`Tuples/TupleAssignment.cc
     
    24962400@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    24972401@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-TupleAssignment.obj `if test -f 'Tuples/TupleAssignment.cc'; then $(CYGPATH_W) 'Tuples/TupleAssignment.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/TupleAssignment.cc'; fi`
    2498 
    2499 Tuples/driver_cfa_cpp-FunctionChecker.o: Tuples/FunctionChecker.cc
    2500 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-FunctionChecker.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionChecker.Tpo -c -o Tuples/driver_cfa_cpp-FunctionChecker.o `test -f 'Tuples/FunctionChecker.cc' || echo '$(srcdir)/'`Tuples/FunctionChecker.cc
    2501 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionChecker.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionChecker.Po
    2502 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/FunctionChecker.cc' object='Tuples/driver_cfa_cpp-FunctionChecker.o' libtool=no @AMDEPBACKSLASH@
    2503 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2504 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-FunctionChecker.o `test -f 'Tuples/FunctionChecker.cc' || echo '$(srcdir)/'`Tuples/FunctionChecker.cc
    2505 
    2506 Tuples/driver_cfa_cpp-FunctionChecker.obj: Tuples/FunctionChecker.cc
    2507 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-FunctionChecker.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionChecker.Tpo -c -o Tuples/driver_cfa_cpp-FunctionChecker.obj `if test -f 'Tuples/FunctionChecker.cc'; then $(CYGPATH_W) 'Tuples/FunctionChecker.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/FunctionChecker.cc'; fi`
    2508 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionChecker.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionChecker.Po
    2509 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Tuples/FunctionChecker.cc' object='Tuples/driver_cfa_cpp-FunctionChecker.obj' libtool=no @AMDEPBACKSLASH@
    2510 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2511 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-FunctionChecker.obj `if test -f 'Tuples/FunctionChecker.cc'; then $(CYGPATH_W) 'Tuples/FunctionChecker.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/FunctionChecker.cc'; fi`
    25122402
    25132403Tuples/driver_cfa_cpp-NameMatcher.o: Tuples/NameMatcher.cc
     
    26542544        -rm -f ControlStruct/$(DEPDIR)/$(am__dirstamp)
    26552545        -rm -f ControlStruct/$(am__dirstamp)
    2656         -rm -f Designators/$(DEPDIR)/$(am__dirstamp)
    2657         -rm -f Designators/$(am__dirstamp)
    26582546        -rm -f GenPoly/$(DEPDIR)/$(am__dirstamp)
    26592547        -rm -f GenPoly/$(am__dirstamp)
     
    26852573
    26862574distclean: distclean-am
    2687         -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) Common/$(DEPDIR) ControlStruct/$(DEPDIR) Designators/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR)
     2575        -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) Common/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR)
    26882576        -rm -f Makefile
    26892577distclean-am: clean-am distclean-compile distclean-generic \
     
    27312619
    27322620maintainer-clean: maintainer-clean-am
    2733         -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) Common/$(DEPDIR) ControlStruct/$(DEPDIR) Designators/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR)
     2621        -rm -rf ./$(DEPDIR) CodeGen/$(DEPDIR) Common/$(DEPDIR) ControlStruct/$(DEPDIR) GenPoly/$(DEPDIR) InitTweak/$(DEPDIR) Parser/$(DEPDIR) ResolvExpr/$(DEPDIR) SymTab/$(DEPDIR) SynTree/$(DEPDIR) Tuples/$(DEPDIR)
    27342622        -rm -f Makefile
    27352623maintainer-clean-am: distclean-am maintainer-clean-generic
     
    27662654
    27672655
    2768 #SRC +=  ArgTweak/Rewriter.cc \
    2769 #       ArgTweak/Mutate.cc
    2770 
    2771 #       Tuples/MultipleAssign.cc \
    2772 #       Tuples/FlattenTuple.cc \
    2773 #       Tuples/MultRet.cc \
    2774 #       Tuples/FixReturn.cc \
    2775 #       Tuples/MassAssignment.cc \
    2776 #       Tuples/TupleFixer.cc
    2777 
    27782656# Tell versions [3.59,3.63) of GNU make to not export all variables.
    27792657# Otherwise a system limit (for SysV at least) may be exceeded.
  • src/Parser/ParseNode.cc

    r28307be r3403534  
    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
     21std::ostream & operator<<( std::ostream & out, const ParseNode * node ) {
     22  node->print( out );
     23  return out;
     24}
     25
    2126// Local Variables: //
    2227// tab-width: 4 //
  • src/Parser/ParseNode.h

    r28307be r3403534  
    431431}
    432432
     433// in ParseNode.cc
     434std::ostream & operator<<( std::ostream & out, const ParseNode * node );
    433435
    434436#endif // PARSENODE_H
  • src/ResolvExpr/AlternativeFinder.cc

    r28307be r3403534  
    3838#include "SynTree/TypeSubstitution.h"
    3939#include "SymTab/Validate.h"
    40 #include "Designators/Processor.h"
    4140#include "Tuples/TupleAssignment.h"
    4241#include "Tuples/NameMatcher.h"
    4342#include "Common/utility.h"
    4443#include "InitTweak/InitTweak.h"
     44#include "ResolveTypeof.h"
    4545
    4646extern bool resolvep;
     
    708708        void AlternativeFinder::visit( CastExpr *castExpr ) {
    709709                for ( std::list< Type* >::iterator i = castExpr->get_results().begin(); i != castExpr->get_results().end(); ++i ) {
     710                        *i = resolveTypeof( *i, indexer );
    710711                        SymTab::validateType( *i, &indexer );
    711712                        adjustExprType( *i, env, indexer );
     
    796797
    797798        void AlternativeFinder::visit( VariableExpr *variableExpr ) {
    798                 alternatives.push_back( Alternative( variableExpr->clone(), env, Cost::zero ) );
     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 ) );
    799802        }
    800803
     
    805808        void AlternativeFinder::visit( SizeofExpr *sizeofExpr ) {
    806809                if ( sizeofExpr->get_isType() ) {
     810                        // xxx - resolveTypeof?
    807811                        alternatives.push_back( Alternative( sizeofExpr->clone(), env, Cost::zero ) );
    808812                } else {
     
    824828        void AlternativeFinder::visit( AlignofExpr *alignofExpr ) {
    825829                if ( alignofExpr->get_isType() ) {
     830                        // xxx - resolveTypeof?
    826831                        alternatives.push_back( Alternative( alignofExpr->clone(), env, Cost::zero ) );
    827832                } else {
     
    857862        void AlternativeFinder::visit( UntypedOffsetofExpr *offsetofExpr ) {
    858863                AlternativeFinder funcFinder( indexer, env );
     864                // xxx - resolveTypeof?
    859865                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( offsetofExpr->get_type() ) ) {
    860866                        addOffsetof( structInst, offsetofExpr->get_member() );
  • src/ResolvExpr/Resolver.cc

    r28307be r3403534  
    528528
    529529        void Resolver::visit( ConstructorInit *ctorInit ) {
    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                 }
     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 );
    539533
    540534                // found a constructor - can get rid of C-style initializer
  • src/SymTab/Autogen.cc

    r28307be r3403534  
    6464
    6565        template< typename OutputIterator >
    66         void makeUnionFieldsAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, UnionInstType *unionType, OutputIterator out ) {
     66        void makeUnionFieldsAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, OutputIterator out ) {
    6767                UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) );
    6868                copy->get_args().push_back( new VariableExpr( dstParam ) );
     
    413413                dtorDecl->fixUniqueId();
    414414
    415                 makeUnionFieldsAssignment( srcParam, dstParam, cloneWithParams( refType, unionParams ), back_inserter( assignDecl->get_statements()->get_kids() ) );
    416                 if ( isDynamicLayout ) makeUnionFieldsAssignment( srcParam, returnVal, cloneWithParams( refType, unionParams ), back_inserter( assignDecl->get_statements()->get_kids() ) );
     415                makeUnionFieldsAssignment( srcParam, dstParam, back_inserter( assignDecl->get_statements()->get_kids() ) );
     416                if ( isDynamicLayout ) makeUnionFieldsAssignment( srcParam, returnVal, back_inserter( assignDecl->get_statements()->get_kids() ) );
    417417                else assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
    418418
     
    434434                                ctor->fixUniqueId();
    435435
    436                                 makeUnionFieldsAssignment( srcParam, dstParam, cloneWithParams( refType, unionParams ), back_inserter( ctor->get_statements()->get_kids() ) );
     436                                makeUnionFieldsAssignment( srcParam, dstParam, back_inserter( ctor->get_statements()->get_kids() ) );
    437437                                memCtors.push_back( ctor );
    438438                                // only generate a ctor for the first field
  • src/SymTab/Autogen.h

    r28307be r3403534  
    102102                }
    103103
    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*>() ) );
     104                ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );
    110105
    111106                UntypedExpr *cond = new UntypedExpr( cmp );
  • src/SymTab/Indexer.cc

    r28307be r3403534  
    2121#include <unordered_set>
    2222#include <utility>
     23#include <algorithm>
    2324
    2425#include "Mangler.h"
     
    3334#include "SynTree/Initializer.h"
    3435#include "SynTree/Statement.h"
     36
     37#include "InitTweak/InitTweak.h"
    3538
    3639#define debugPrint(x) if ( doDebug ) { std::cout << x; }
     
    99102
    100103                if ( --toFree->refCount == 0 ) delete toFree;
     104        }
     105
     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                }
    101166        }
    102167
     
    461526                        searchTables = searchTables->base.tables;
    462527                }
     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 );
    463533        }
    464534
  • src/SymTab/Indexer.h

    r28307be r3403534  
    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
    130135                /// Ensures that tables variable is writable (i.e. allocated, uniquely owned by this Indexer, and at the current scope)
    131136                void makeWritable();
  • src/SymTab/Validate.cc

    r28307be r3403534  
    8686
    8787        /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers.
    88         class Pass1 : public Visitor {
     88        class EnumAndPointerDecayPass : public Visitor {
    8989                typedef Visitor Parent;
    9090                virtual void visit( EnumDecl *aggregateDecl );
     
    189189
    190190        void validate( std::list< Declaration * > &translationUnit, bool doDebug ) {
    191                 Pass1 pass1;
     191                EnumAndPointerDecayPass epc;
    192192                Pass2 pass2( doDebug, 0 );
    193193                Pass3 pass3( 0 );
     
    196196                EliminateTypedef::eliminateTypedef( translationUnit );
    197197                HoistStruct::hoistStruct( translationUnit );
    198                 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs Pass1
    199                 acceptAll( translationUnit, pass1 );
     198                autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecayPass
     199                acceptAll( translationUnit, epc );
    200200                acceptAll( translationUnit, pass2 );
    201201                ReturnChecker::checkFunctionReturns( translationUnit );
     
    206206
    207207        void validateType( Type *type, const Indexer *indexer ) {
    208                 Pass1 pass1;
     208                EnumAndPointerDecayPass epc;
    209209                Pass2 pass2( false, indexer );
    210210                Pass3 pass3( indexer );
    211                 type->accept( pass1 );
     211                type->accept( epc );
    212212                type->accept( pass2 );
    213213                type->accept( pass3 );
     
    272272        }
    273273
    274         void Pass1::visit( EnumDecl *enumDecl ) {
     274        void EnumAndPointerDecayPass::visit( EnumDecl *enumDecl ) {
    275275                // Set the type of each member of the enumeration to be EnumConstant
    276276                for ( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) {
     
    296296                                DWTIterator j = i;
    297297                                ++i;
     298                                delete *j;
    298299                                dwts.erase( j );
    299300                                if ( i != end ) {
     
    313314        }
    314315
    315         void Pass1::visit( FunctionType *func ) {
     316        void EnumAndPointerDecayPass::visit( FunctionType *func ) {
    316317                // Fix up parameters and return types
    317318                fixFunctionList( func->get_parameters(), func );
  • src/SynTree/Declaration.cc

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

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

    r28307be r3403534  
    358358        assert( member );
    359359        os << std::string( indent + 2, ' ' );
    360         os << (void*)member << " ";
    361360        member->print( os, indent + 2 );
    362361        os << std::endl;
     
    541540}
    542541
    543 std::ostream & operator<<( std::ostream & out, Expression * expr ) {
     542std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
    544543        expr->print( out );
    545544        return out;
  • src/SynTree/Expression.h

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

    r28307be r3403534  
    2121#include "Attribute.h"
    2222#include "Common/utility.h"
     23#include "InitTweak/InitTweak.h"
    2324
    2425FunctionDecl::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

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

    r28307be r3403534  
    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 ); }
    4951
    5052        virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); }
     
    395397
    396398
    397 std::ostream & operator<<( std::ostream & out, Statement * statement );
     399std::ostream & operator<<( std::ostream & out, const Statement * statement );
    398400
    399401#endif // STATEMENT_H
  • src/SynTree/Type.cc

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

    r28307be r3403534  
    481481}
    482482
    483 std::ostream & operator<<( std::ostream & out, Type * type );
     483std::ostream & operator<<( std::ostream & out, const Type * type );
    484484
    485485#endif // TYPE_H
  • src/Tuples/module.mk

    r28307be r3403534  
    1515###############################################################################
    1616
    17 SRC +=  Tuples/Mutate.cc \
    18         Tuples/AssignExpand.cc \
    19         Tuples/FunctionFixer.cc \
    20         Tuples/TupleAssignment.cc \
    21         Tuples/FunctionChecker.cc \
     17SRC +=  Tuples/TupleAssignment.cc \
    2218        Tuples/NameMatcher.cc
    23 
    24 #       Tuples/MultipleAssign.cc \
    25 #       Tuples/FlattenTuple.cc \
    26 #       Tuples/MultRet.cc \
    27 #       Tuples/FixReturn.cc \
    28 #       Tuples/MassAssignment.cc \
    29 #       Tuples/TupleFixer.cc
  • src/tests/.expect/64/declarationSpecifier.txt

    r28307be r3403534  
    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

    r28307be r3403534  
    8686        __extension__ int __c__i_2;
    8787    };
    88     int __i__i_2;
    89     ((void)((*((int *)(&__i__i_2)))=(__extension__ __a__i_1+__extension__ 3)) /* ?{} */);
     88    int __i__i_2 = ((int )(__extension__ __a__i_1+__extension__ 3));
    9089    ((void)__extension__ 3);
    9190    ((void)__extension__ __a__i_1);
  • src/tests/.expect/64/gccExtensions.txt

    r28307be r3403534  
    7676        ((void)((*((int *)(&(*___dst__P2sS_2).__c__i_2)))=__c__i_2) /* ?{} */);
    7777    }
    78     int __i__i_2;
    79     ((void)((*((int *)(&__i__i_2)))=__extension__ 3) /* ?{} */);
     78    int __i__i_2 = ((int )__extension__ 3);
    8079    __extension__ int __a__i_2;
    8180    __extension__ int __b__i_2;
     
    133132    }
    134133    struct s3 __x1__3ss3_2;
    135     ((void)___constructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));
    136134    struct s3 __y1__3ss3_2;
    137     ((void)___constructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));
    138135    struct s4 {
    139136        int __i__i_2;
     
    141138    inline struct s4 ___operator_assign__F3ss4_P3ss43ss4_autogen___2(struct s4 *___dst__P3ss4_2, struct s4 ___src__3ss4_2){
    142139        ((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))));
    145140        return ((struct s4 )___src__3ss4_2);
    146141    }
     
    158153    }
    159154    struct s4 __x2__3ss4_2;
    160     ((void)___constructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));
    161155    struct s4 __y2__3ss4_2;
    162     ((void)___constructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));
    163156    int __m1__A0i_2[((long unsigned int )10)];
    164157    int __m2__A0A0i_2[((long unsigned int )10)][((long unsigned int )10)];
     
    166159    int _retVal0 = { 0 };
    167160    ((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))));
    172161    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))));
    177162}
  • src/tests/Makefile.am

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

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

    r28307be r3403534  
    22from __future__ import print_function
    33
     4from functools import partial
     5from multiprocessing import Pool
    46from os import listdir, environ
    57from os.path import isfile, join, splitext
     
    102104#               running test functions
    103105################################################################################
    104 def run_test_instance(test, generate, dry_run):
     106def run_single_test(test, generate, dry_run):
    105107
    106108        # find the output file based on the test name and options flag
     
    163165        return retcode, error
    164166
     167def run_test_instance(t, generate, dry_run) :
     168        # print formated name
     169        name_txt = "%20s  " % t.name
     170
     171        #run the test instance and collect the result
     172        test_failed, error = run_single_test(t, generate, dry_run)
     173
     174        # update output based on current action
     175        if generate :
     176                failed_txt = "ERROR"
     177                success_txt = "Done"
     178        else :
     179                failed_txt = "FAILED"
     180                success_txt = "PASSED"
     181
     182        #print result with error if needed
     183        text = name_txt + (failed_txt if test_failed else success_txt)
     184        out = sys.stdout
     185        if error :
     186                text = text + "\n" + error
     187                out = sys.stderr
     188
     189        print(text, file = out);
     190        sys.stdout.flush()
     191        sys.stderr.flush()
     192
     193        return test_failed
     194
    165195# run the given list of tests with the given parameters
    166196def run_tests(tests, generate, dry_run, jobs) :
     
    174204                print( "Regenerate tests for: " )
    175205
    176         failed = False;
    177         # for eeach test to run
    178         for t in tests:
    179                 # print formated name
    180                 name_txt = "%20s  " % t.name
    181 
    182                 #run the test instance and collect the result
    183                 test_failed, error = run_test_instance(t, generate, dry_run)
    184 
    185                 # aggregate test suite result
    186                 failed = test_failed or failed
    187 
    188                 # update output based on current action
    189                 if generate :
    190                         failed_txt = "ERROR"
    191                         success_txt = "Done"
    192                 else :
    193                         failed_txt = "FAILED"
    194                         success_txt = "PASSED"
    195 
    196                 #print result with error if needed
    197                 text = name_txt + (failed_txt if test_failed else success_txt)
    198                 out = sys.stdout
    199                 if error :
    200                         text = text + "\n" + error
    201                         out = sys.stderr
    202 
    203                 print(text, file = out);
    204                 sys.stdout.flush()
    205                 sys.stderr.flush()
    206 
     206        # for each test to run
     207        pool = Pool(jobs)
     208        try :
     209                results = pool.map_async(partial(run_test_instance, generate=generate, dry_run=dry_run), tests ).get(99999999)
     210        except KeyboardInterrupt:
     211                pool.terminate()
     212                print("Tests interrupted by user")
     213                sys.exit(1)
    207214
    208215        #clean the workspace
    209216        sh("%s clean > /dev/null 2>&1" % make_cmd, dry_run)
    210217
    211         return 1 if failed else 0
     218        for failed in results:
     219                if failed :
     220                        return 1
     221
     222        return 0
    212223
    213224################################################################################
     
    279290
    280291# make sure we have a valid number of jobs that corresponds to user input
    281 options.jobs = int(make_max_jobs) if make_max_jobs else options.jobs
     292options.jobs = int(make_max_jobs) if make_max_jobs else (options.jobs if options.jobs else 1)
    282293if options.jobs <= 0 :
    283294        print('ERROR: Invalid number of jobs', file=sys.stderr)
    284295        sys.exit(1)
    285296
     297print('Running on %i cores' % options.jobs)
     298
    286299# users may want to simply list the tests
    287300if options.list :
  • src/tests/typeof.c

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