Changeset 3403534
- Timestamp:
- Sep 4, 2016, 10:34:35 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 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. - Location:
- src
- Files:
-
- 3 added
- 35 deleted
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/SemanticError.cc
r28307be r3403534 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // SemanticError.cc -- 7 // SemanticError.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 26 26 27 27 SemanticError::SemanticError( std::string error ) { 28 errors.push_back( std::string( "Error: " ) +error );28 append( error ); 29 29 } 30 30 31 31 void SemanticError::append( SemanticError &other ) { 32 errors.splice( errors.end(), other.errors ); 32 errors.splice( errors.end(), other.errors ); 33 } 34 35 void SemanticError::append( const std::string & msg ) { 36 errors.push_back( std::string( "Error: ") + msg ); 33 37 } 34 38 -
src/Common/SemanticError.h
r28307be r3403534 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // SemanticError.h -- 7 // SemanticError.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 31 31 32 32 void append( SemanticError &other ); 33 void append( const std::string & ); 33 34 bool isEmpty() const; 34 35 void print( std::ostream &os ); … … 42 43 template< typename T > 43 44 SemanticError::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 ) ); 48 46 } 47 49 48 50 49 #endif // SEMANTICERROR_H -
src/Common/utility.h
r28307be r3403534 246 246 } 247 247 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 253 template< typename T > 254 struct ValueGuard { 255 T old; 256 T& ref; 257 258 ValueGuard(T& inRef) : old(inRef), ref(inRef) {} 259 ~ValueGuard() { ref = old; } 260 }; 261 262 template< typename T > 263 struct 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 273 template< typename T > 274 reverseIterate_t< T > reverseIterate( T & ref ) { 275 return reverseIterate_t< T >( ref ); 276 } 277 248 278 #endif // _UTILITY_H 249 279 -
src/GenPoly/Box.cc
r28307be r3403534 158 158 class PolyGenericCalculator : public PolyMutator { 159 159 public: 160 typedef PolyMutator Parent; 161 using Parent::mutate; 162 160 163 template< typename DeclClass > 161 164 DeclClass *handleDecl( DeclClass *decl, Type *type ); … … 1675 1678 DeclClass * PolyGenericCalculator::handleDecl( DeclClass *decl, Type *type ) { 1676 1679 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 ) { 1677 1696 knownLayouts.beginScope(); 1678 1697 knownOffsets.beginScope(); 1679 1698 1680 DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) ); 1681 1699 DeclarationWithType * decl = handleDecl( functionDecl, functionDecl->get_functionType() ); 1682 1700 knownOffsets.endScope(); 1683 1701 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; 1694 1703 } 1695 1704 … … 1700 1709 TypeDecl * PolyGenericCalculator::mutate( TypeDecl *typeDecl ) { 1701 1710 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind(); 1702 return Mutator::mutate( typeDecl );1711 return Parent::mutate( typeDecl ); 1703 1712 } 1704 1713 … … 1706 1715 beginTypeScope( pointerType ); 1707 1716 1708 Type *ret = Mutator::mutate( pointerType );1717 Type *ret = Parent::mutate( pointerType ); 1709 1718 1710 1719 endTypeScope(); … … 1724 1733 } 1725 1734 1726 Type *ret = Mutator::mutate( funcType );1735 Type *ret = Parent::mutate( funcType ); 1727 1736 1728 1737 endTypeScope(); … … 1745 1754 } 1746 1755 } 1747 return Mutator::mutate( declStmt );1756 return Parent::mutate( declStmt ); 1748 1757 } 1749 1758 … … 1787 1796 Expression *PolyGenericCalculator::mutate( MemberExpr *memberExpr ) { 1788 1797 // mutate, exiting early if no longer MemberExpr 1789 Expression *expr = Mutator::mutate( memberExpr );1798 Expression *expr = Parent::mutate( memberExpr ); 1790 1799 memberExpr = dynamic_cast< MemberExpr* >( expr ); 1791 1800 if ( ! memberExpr ) return expr; … … 1972 1981 Expression *PolyGenericCalculator::mutate( OffsetofExpr *offsetofExpr ) { 1973 1982 // mutate, exiting early if no longer OffsetofExpr 1974 Expression *expr = Mutator::mutate( offsetofExpr );1983 Expression *expr = Parent::mutate( offsetofExpr ); 1975 1984 offsetofExpr = dynamic_cast< OffsetofExpr* >( expr ); 1976 1985 if ( ! offsetofExpr ) return expr; -
src/GenPoly/PolyMutator.h
r28307be r3403534 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // PolyMutator.h -- 7 // PolyMutator.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 30 30 class PolyMutator : public Mutator { 31 31 public: 32 typedef Mutator Parent; 33 using Parent::mutate; 34 32 35 PolyMutator(); 33 36 … … 42 45 virtual Statement* mutate(ExprStmt *catchStmt); 43 46 virtual Statement* mutate(ReturnStmt *catchStmt); 44 47 45 48 virtual Expression* mutate(UntypedExpr *untypedExpr); 46 49 … … 54 57 Statement* mutateStatement( Statement *stmt ); 55 58 Expression* mutateExpression( Expression *expr ); 56 59 57 60 TyVarMap scopeTyVars; 58 61 TypeSubstitution *env; … … 60 63 std::list< Statement* > stmtsToAddAfter; 61 64 }; 62 } // namespace 65 } // namespace 63 66 64 67 #endif // _POLYMUTATOR_H -
src/InitTweak/FixInit.cc
r28307be r3403534 31 31 #include "SynTree/Mutator.h" 32 32 #include "SymTab/Indexer.h" 33 #include "SymTab/Autogen.h" 33 34 #include "GenPoly/PolyMutator.h" 34 35 #include "SynTree/AddStmtVisitor.h" … … 176 177 }; 177 178 178 class WarnStructMembers : public Visitor {179 class GenStructMemberCalls : public SymTab::Indexer { 179 180 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 ); 184 186 185 187 virtual void visit( FunctionDecl * funcDecl ); … … 188 190 virtual void visit( ApplicationExpr * appExpr ); 189 191 192 SemanticError errors; 190 193 private: 191 194 void handleFirstParam( Expression * firstParam ); 195 template< typename... Params > 196 void emit( const Params &... params ); 192 197 193 198 FunctionDecl * function = 0; 194 std::set< DeclarationWithType * > unhandled ;199 std::set< DeclarationWithType * > unhandled, usedUninit; 195 200 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; 196 217 }; 197 218 } // namespace … … 209 230 FixCopyCtors::fixCopyCtors( translationUnit ); 210 231 211 WarnStructMembers::warnings( translationUnit );232 GenStructMemberCalls::generate( translationUnit ); 212 233 } 213 234 … … 254 275 } 255 276 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; 260 284 } 261 285 } … … 528 552 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false ); 529 553 dtorCaller->fixUniqueId(); 530 dtorCaller->get_statements()-> get_kids().push_back( dtorStmt );554 dtorCaller->get_statements()->push_back( dtorStmt ); 531 555 532 556 // atexit(dtor_atexit); … … 543 567 // at global scope and there could be multiple function-scoped 544 568 // 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. 545 574 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 ) ); 547 577 548 578 objDecl->set_init( NULL ); … … 709 739 } 710 740 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(); 714 752 715 753 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(); 718 757 assert( ! type->get_parameters().empty() ); 719 758 thisParam = safe_dynamic_cast< ObjectDecl * >( type->get_parameters().front() ); … … 721 760 StructInstType * structType = dynamic_cast< StructInstType * >( ptrType->get_base() ); 722 761 if ( structType ) { 723 StructDecl *structDecl = structType->get_baseStruct();762 structDecl = structType->get_baseStruct(); 724 763 for ( Declaration * member : structDecl->get_members() ) { 725 764 if ( ObjectDecl * field = dynamic_cast< ObjectDecl * >( member ) ) { … … 731 770 } 732 771 } 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" ); 738 780 } 739 781 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 ) { 744 834 if ( ! checkWarnings( function ) ) return; 745 835 … … 760 850 handleFirstParam( firstParam ); 761 851 } 762 } else if ( fname == "?=?" && isIntrinsicCallExpr( appExpr ) ) {763 // forgive use of intrinsic assignment to construct, since instrinsic constructors764 // codegen as assignment anyway.765 assert( appExpr->get_args().size() == 2 );766 handleFirstParam( appExpr->get_args().front() );767 852 } 768 853 … … 770 855 } 771 856 772 void WarnStructMembers::handleFirstParam( Expression * firstParam ) {857 void GenStructMemberCalls::handleFirstParam( Expression * firstParam ) { 773 858 using namespace std; 774 859 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( firstParam ) ) { … … 787 872 } 788 873 789 void WarnStructMembers::visit( MemberExpr * memberExpr ) {874 void GenStructMemberCalls::visit( MemberExpr * memberExpr ) { 790 875 if ( ! checkWarnings( function ) ) return; 791 if ( ! isC onstructor( function->get_name() )) return;876 if ( ! isCtor ) return; 792 877 793 878 if ( ApplicationExpr * deref = dynamic_cast< ApplicationExpr * >( memberExpr->get_aggregate() ) ) { … … 797 882 if ( unhandled.count( memberExpr->get_member() ) ) { 798 883 // 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() ); 800 885 } 801 886 } … … 805 890 Parent::visit( memberExpr ); 806 891 } 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 } 807 916 } // namespace 808 917 } // namespace InitTweak -
src/InitTweak/GenInit.cc
r28307be r3403534 25 25 #include "SynTree/Mutator.h" 26 26 #include "SymTab/Autogen.h" 27 #include "SymTab/Mangler.h" 27 28 #include "GenPoly/PolyMutator.h" 28 29 #include "GenPoly/DeclMutator.h" 30 #include "GenPoly/ScopedSet.h" 29 31 30 32 namespace InitTweak { … … 55 57 class CtorDtor : public GenPoly::PolyMutator { 56 58 public: 59 typedef GenPoly::PolyMutator Parent; 60 using Parent::mutate; 57 61 /// create constructor and destructor statements for object declarations. 58 62 /// the actual call statements will be added in after the resolver has run … … 65 69 // should not traverse into any of these declarations to find objects 66 70 // that need to be constructed or destructed 67 virtual Declaration* mutate( StructDecl *aggregateDecl ) { return aggregateDecl; }71 virtual Declaration* mutate( StructDecl *aggregateDecl ); 68 72 virtual Declaration* mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; } 69 73 virtual Declaration* mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; } … … 74 78 virtual Type * mutate( FunctionType *funcType ) { return funcType; } 75 79 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; 77 91 }; 78 92 … … 142 156 143 157 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 ); 146 160 147 161 FunctionType * type = functionDecl->get_functionType(); … … 149 163 funcName = functionDecl->get_name(); 150 164 DeclarationWithType * decl = Mutator::mutate( functionDecl ); 151 returnVals = oldReturnVals;152 funcName = oldFuncName;153 165 return decl; 154 166 } … … 197 209 198 210 DeclarationWithType * HoistArrayDimension::mutate( FunctionDecl *functionDecl ) { 199 bool oldInFunc = inFunction;211 ValueGuard< bool > oldInFunc( inFunction ); 200 212 inFunction = true; 201 213 DeclarationWithType * decl = Parent::mutate( functionDecl ); 202 inFunction = oldInFunc;203 214 return decl; 204 215 } … … 209 220 } 210 221 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 211 240 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 214 249 // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor 215 250 // for each constructable object … … 241 276 } 242 277 } 243 return Mutator::mutate( objDecl );278 return Parent::mutate( objDecl ); 244 279 } 245 280 246 281 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 } 247 294 // parameters should not be constructed and destructed, so don't mutate FunctionType 248 295 mutateAll( functionDecl->get_oldDecls(), *this ); 249 296 functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) ); 297 298 managedTypes.endScope(); 250 299 return functionDecl; 251 300 } 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 252 323 } // namespace InitTweak 253 324 -
src/InitTweak/InitTweak.cc
r28307be r3403534 7 7 #include "SynTree/Attribute.h" 8 8 #include "GenPoly/GenPoly.h" 9 #include "ResolvExpr/typeops.h" 9 10 10 11 namespace InitTweak { … … 79 80 public: 80 81 ExprImpl( Expression * expr ) : arg( expr ) {} 82 83 ~ExprImpl() { delete arg; } 81 84 82 85 virtual std::list< Expression * > next( std::list< Expression * > & indices ) { … … 122 125 123 126 void InitExpander::clearArrayIndices() { 127 deleteAll( indices ); 124 128 indices.clear(); 125 129 } … … 228 232 return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) && 229 233 (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() )) 232 235 && objDecl->get_storageClass() != DeclarationNode::Extern; 233 236 } … … 387 390 virtual void visit( ApplicationExpr *applicationExpr ) { isConstExpr = false; } 388 391 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 } 391 402 virtual void visit( LabelAddressExpr *labAddressExpr ) { isConstExpr = false; } 392 403 virtual void visit( UntypedMemberExpr *memberExpr ) { isConstExpr = false; } 393 404 virtual void visit( MemberExpr *memberExpr ) { isConstExpr = false; } 394 405 virtual void visit( VariableExpr *variableExpr ) { isConstExpr = false; } 395 virtual void visit( ConstantExpr *constantExpr ) { /* bottom out */ }396 406 // these might be okay? 397 407 // virtual void visit( SizeofExpr *sizeofExpr ); … … 436 446 bool isDestructor( const std::string & str ) { return str == "^?{}"; } 437 447 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 } 438 467 } -
src/InitTweak/InitTweak.h
r28307be r3403534 29 29 bool isDestructor( const std::string & ); 30 30 bool isCtorDtor( const std::string & ); 31 32 FunctionDecl * isCopyConstructor( Declaration * decl ); 31 33 32 34 /// transform Initializer into an argument list that can be passed to a call expression -
src/Makefile.am
r28307be r3403534 25 25 # Is there a way to use a variable for the directory names? 26 26 27 include ArgTweak/module.mk28 27 include CodeGen/module.mk 29 28 include Common/module.mk 30 29 include ControlStruct/module.mk 31 include Designators/module.mk32 30 include GenPoly/module.mk 33 31 include InitTweak/module.mk -
src/Makefile.in
r28307be r3403534 22 22 ############################################################################### 23 23 24 ######################### -*- Mode: Makefile-Gmake -*- ########################25 ###############################################################################26 27 24 #SRC += ArgTweak/Rewriter.cc \ 28 25 # ArgTweak/Mutate.cc 29 30 ######################### -*- Mode: Makefile-Gmake -*- ########################31 ###############################################################################32 26 33 27 ######################### -*- Mode: Makefile-Gmake -*- ######################## … … 75 69 PRE_UNINSTALL = : 76 70 POST_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 \ 71 DIST_COMMON = $(srcdir)/CodeGen/module.mk $(srcdir)/Common/module.mk \ 72 $(srcdir)/ControlStruct/module.mk $(srcdir)/GenPoly/module.mk \ 80 73 $(srcdir)/InitTweak/module.mk $(srcdir)/Makefile.am \ 81 74 $(srcdir)/Makefile.in $(srcdir)/Parser/module.mk \ … … 112 105 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \ 113 106 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT) \ 114 Designators/driver_cfa_cpp-Processor.$(OBJEXT) \115 107 GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \ 116 108 GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \ … … 196 188 SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \ 197 189 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) \201 190 Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \ 202 Tuples/driver_cfa_cpp-FunctionChecker.$(OBJEXT) \203 191 Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT) 204 192 am_driver_cfa_cpp_OBJECTS = $(am__objects_1) … … 374 362 ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \ 375 363 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 \ 378 366 GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \ 379 367 GenPoly/CopyParams.cc GenPoly/FindFunction.cc \ … … 413 401 SynTree/Initializer.cc SynTree/Visitor.cc SynTree/Mutator.cc \ 414 402 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 418 405 MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \ 419 406 ${cfa_cpplib_PROGRAMS}} … … 433 420 .SUFFIXES: 434 421 .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) 436 423 @for dep in $?; do \ 437 424 case '$(am__configure_deps)' in \ … … 454 441 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 455 442 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: 457 444 458 445 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) … … 553 540 ControlStruct/$(am__dirstamp) \ 554 541 ControlStruct/$(DEPDIR)/$(am__dirstamp) 555 Designators/$(am__dirstamp):556 @$(MKDIR_P) Designators557 @: > 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)564 542 GenPoly/$(am__dirstamp): 565 543 @$(MKDIR_P) GenPoly … … 789 767 @$(MKDIR_P) Tuples/$(DEPDIR) 790 768 @: > 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)797 769 Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT): \ 798 Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp)799 Tuples/driver_cfa_cpp-FunctionChecker.$(OBJEXT): \800 770 Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp) 801 771 Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT): Tuples/$(am__dirstamp) \ … … 824 794 -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) 825 795 -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) 826 -rm -f Designators/driver_cfa_cpp-Processor.$(OBJEXT)827 796 -rm -f GenPoly/driver_cfa_cpp-Box.$(OBJEXT) 828 797 -rm -f GenPoly/driver_cfa_cpp-CopyParams.$(OBJEXT) … … 908 877 -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT) 909 878 -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)914 879 -rm -f Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT) 915 880 -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) … … 934 899 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@ 935 900 @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@937 901 @AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-Box.Po@am__quote@ 938 902 @AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-CopyParams.Po@am__quote@ … … 1018 982 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@ 1019 983 @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@1024 984 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po@am__quote@ 1025 985 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@ … … 1265 1225 @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` 1266 1226 1267 Designators/driver_cfa_cpp-Processor.o: Designators/Processor.cc1268 @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.cc1269 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Designators/$(DEPDIR)/driver_cfa_cpp-Processor.Tpo Designators/$(DEPDIR)/driver_cfa_cpp-Processor.Po1270 @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.cc1273 1274 Designators/driver_cfa_cpp-Processor.obj: Designators/Processor.cc1275 @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.Po1277 @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 1281 1227 GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc 1282 1228 @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 … … 2441 2387 @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` 2442 2388 2443 Tuples/driver_cfa_cpp-Mutate.o: Tuples/Mutate.cc2444 @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.cc2445 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-Mutate.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-Mutate.Po2446 @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.cc2449 2450 Tuples/driver_cfa_cpp-Mutate.obj: Tuples/Mutate.cc2451 @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.Po2453 @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.cc2458 @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.cc2459 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-AssignExpand.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-AssignExpand.Po2460 @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.cc2463 2464 Tuples/driver_cfa_cpp-AssignExpand.obj: Tuples/AssignExpand.cc2465 @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.Po2467 @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.cc2472 @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.cc2473 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionFixer.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionFixer.Po2474 @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.cc2477 2478 Tuples/driver_cfa_cpp-FunctionFixer.obj: Tuples/FunctionFixer.cc2479 @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.Po2481 @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 2485 2389 Tuples/driver_cfa_cpp-TupleAssignment.o: Tuples/TupleAssignment.cc 2486 2390 @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 … … 2496 2400 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2497 2401 @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.cc2500 @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.cc2501 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionChecker.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-FunctionChecker.Po2502 @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.cc2505 2506 Tuples/driver_cfa_cpp-FunctionChecker.obj: Tuples/FunctionChecker.cc2507 @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.Po2509 @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`2512 2402 2513 2403 Tuples/driver_cfa_cpp-NameMatcher.o: Tuples/NameMatcher.cc … … 2654 2544 -rm -f ControlStruct/$(DEPDIR)/$(am__dirstamp) 2655 2545 -rm -f ControlStruct/$(am__dirstamp) 2656 -rm -f Designators/$(DEPDIR)/$(am__dirstamp)2657 -rm -f Designators/$(am__dirstamp)2658 2546 -rm -f GenPoly/$(DEPDIR)/$(am__dirstamp) 2659 2547 -rm -f GenPoly/$(am__dirstamp) … … 2685 2573 2686 2574 distclean: 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) 2688 2576 -rm -f Makefile 2689 2577 distclean-am: clean-am distclean-compile distclean-generic \ … … 2731 2619 2732 2620 maintainer-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) 2734 2622 -rm -f Makefile 2735 2623 maintainer-clean-am: distclean-am maintainer-clean-generic … … 2766 2654 2767 2655 2768 #SRC += ArgTweak/Rewriter.cc \2769 # ArgTweak/Mutate.cc2770 2771 # Tuples/MultipleAssign.cc \2772 # Tuples/FlattenTuple.cc \2773 # Tuples/MultRet.cc \2774 # Tuples/FixReturn.cc \2775 # Tuples/MassAssignment.cc \2776 # Tuples/TupleFixer.cc2777 2778 2656 # Tell versions [3.59,3.63) of GNU make to not export all variables. 2779 2657 # Otherwise a system limit (for SysV at least) may be exceeded. -
src/Parser/ParseNode.cc
r28307be r3403534 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ParseNode.cc -- 7 // ParseNode.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 12 12 // Last Modified On : Wed Aug 17 23:14:16 2016 13 13 // Update Count : 126 14 // 14 // 15 15 16 16 #include "ParseNode.h" … … 19 19 int ParseNode::indent_by = 4; 20 20 21 std::ostream & operator<<( std::ostream & out, const ParseNode * node ) { 22 node->print( out ); 23 return out; 24 } 25 21 26 // Local Variables: // 22 27 // tab-width: 4 // -
src/Parser/ParseNode.h
r28307be r3403534 431 431 } 432 432 433 // in ParseNode.cc 434 std::ostream & operator<<( std::ostream & out, const ParseNode * node ); 433 435 434 436 #endif // PARSENODE_H -
src/ResolvExpr/AlternativeFinder.cc
r28307be r3403534 38 38 #include "SynTree/TypeSubstitution.h" 39 39 #include "SymTab/Validate.h" 40 #include "Designators/Processor.h"41 40 #include "Tuples/TupleAssignment.h" 42 41 #include "Tuples/NameMatcher.h" 43 42 #include "Common/utility.h" 44 43 #include "InitTweak/InitTweak.h" 44 #include "ResolveTypeof.h" 45 45 46 46 extern bool resolvep; … … 708 708 void AlternativeFinder::visit( CastExpr *castExpr ) { 709 709 for ( std::list< Type* >::iterator i = castExpr->get_results().begin(); i != castExpr->get_results().end(); ++i ) { 710 *i = resolveTypeof( *i, indexer ); 710 711 SymTab::validateType( *i, &indexer ); 711 712 adjustExprType( *i, env, indexer ); … … 796 797 797 798 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 ) ); 799 802 } 800 803 … … 805 808 void AlternativeFinder::visit( SizeofExpr *sizeofExpr ) { 806 809 if ( sizeofExpr->get_isType() ) { 810 // xxx - resolveTypeof? 807 811 alternatives.push_back( Alternative( sizeofExpr->clone(), env, Cost::zero ) ); 808 812 } else { … … 824 828 void AlternativeFinder::visit( AlignofExpr *alignofExpr ) { 825 829 if ( alignofExpr->get_isType() ) { 830 // xxx - resolveTypeof? 826 831 alternatives.push_back( Alternative( alignofExpr->clone(), env, Cost::zero ) ); 827 832 } else { … … 857 862 void AlternativeFinder::visit( UntypedOffsetofExpr *offsetofExpr ) { 858 863 AlternativeFinder funcFinder( indexer, env ); 864 // xxx - resolveTypeof? 859 865 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( offsetofExpr->get_type() ) ) { 860 866 addOffsetof( structInst, offsetofExpr->get_member() ); -
src/ResolvExpr/Resolver.cc
r28307be r3403534 528 528 529 529 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 ); 539 533 540 534 // found a constructor - can get rid of C-style initializer -
src/SymTab/Autogen.cc
r28307be r3403534 64 64 65 65 template< typename OutputIterator > 66 void makeUnionFieldsAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, UnionInstType *unionType,OutputIterator out ) {66 void makeUnionFieldsAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, OutputIterator out ) { 67 67 UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) ); 68 68 copy->get_args().push_back( new VariableExpr( dstParam ) ); … … 413 413 dtorDecl->fixUniqueId(); 414 414 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() ) ); 417 417 else assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 418 418 … … 434 434 ctor->fixUniqueId(); 435 435 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() ) ); 437 437 memCtors.push_back( ctor ); 438 438 // only generate a ctor for the first field -
src/SymTab/Autogen.h
r28307be r3403534 102 102 } 103 103 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*>() ) ); 110 105 111 106 UntypedExpr *cond = new UntypedExpr( cmp ); -
src/SymTab/Indexer.cc
r28307be r3403534 21 21 #include <unordered_set> 22 22 #include <utility> 23 #include <algorithm> 23 24 24 25 #include "Mangler.h" … … 33 34 #include "SynTree/Initializer.h" 34 35 #include "SynTree/Statement.h" 36 37 #include "InitTweak/InitTweak.h" 35 38 36 39 #define debugPrint(x) if ( doDebug ) { std::cout << x; } … … 99 102 100 103 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 } 101 166 } 102 167 … … 461 526 searchTables = searchTables->base.tables; 462 527 } 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 ); 463 533 } 464 534 -
src/SymTab/Indexer.h
r28307be r3403534 128 128 static void deleteRef( Impl *toFree ); 129 129 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 130 135 /// Ensures that tables variable is writable (i.e. allocated, uniquely owned by this Indexer, and at the current scope) 131 136 void makeWritable(); -
src/SymTab/Validate.cc
r28307be r3403534 86 86 87 87 /// 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 { 89 89 typedef Visitor Parent; 90 90 virtual void visit( EnumDecl *aggregateDecl ); … … 189 189 190 190 void validate( std::list< Declaration * > &translationUnit, bool doDebug ) { 191 Pass1 pass1;191 EnumAndPointerDecayPass epc; 192 192 Pass2 pass2( doDebug, 0 ); 193 193 Pass3 pass3( 0 ); … … 196 196 EliminateTypedef::eliminateTypedef( translationUnit ); 197 197 HoistStruct::hoistStruct( translationUnit ); 198 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs Pass1199 acceptAll( translationUnit, pass1);198 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecayPass 199 acceptAll( translationUnit, epc ); 200 200 acceptAll( translationUnit, pass2 ); 201 201 ReturnChecker::checkFunctionReturns( translationUnit ); … … 206 206 207 207 void validateType( Type *type, const Indexer *indexer ) { 208 Pass1 pass1;208 EnumAndPointerDecayPass epc; 209 209 Pass2 pass2( false, indexer ); 210 210 Pass3 pass3( indexer ); 211 type->accept( pass1);211 type->accept( epc ); 212 212 type->accept( pass2 ); 213 213 type->accept( pass3 ); … … 272 272 } 273 273 274 void Pass1::visit( EnumDecl *enumDecl ) {274 void EnumAndPointerDecayPass::visit( EnumDecl *enumDecl ) { 275 275 // Set the type of each member of the enumeration to be EnumConstant 276 276 for ( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) { … … 296 296 DWTIterator j = i; 297 297 ++i; 298 delete *j; 298 299 dwts.erase( j ); 299 300 if ( i != end ) { … … 313 314 } 314 315 315 void Pass1::visit( FunctionType *func ) {316 void EnumAndPointerDecayPass::visit( FunctionType *func ) { 316 317 // Fix up parameters and return types 317 318 fixFunctionList( func->get_parameters(), func ); -
src/SynTree/Declaration.cc
r28307be r3403534 56 56 } 57 57 58 std::ostream & operator<<( std::ostream & out, Declaration * decl ) {58 std::ostream & operator<<( std::ostream & out, const Declaration * decl ) { 59 59 decl->print( out ); 60 60 return out; -
src/SynTree/Declaration.h
r28307be r3403534 279 279 }; 280 280 281 std::ostream & operator<<( std::ostream & out, Declaration * decl );281 std::ostream & operator<<( std::ostream & out, const Declaration * decl ); 282 282 283 283 #endif // DECLARATION_H -
src/SynTree/Expression.cc
r28307be r3403534 358 358 assert( member ); 359 359 os << std::string( indent + 2, ' ' ); 360 os << (void*)member << " ";361 360 member->print( os, indent + 2 ); 362 361 os << std::endl; … … 541 540 } 542 541 543 std::ostream & operator<<( std::ostream & out, Expression * expr ) {542 std::ostream & operator<<( std::ostream & out, const Expression * expr ) { 544 543 expr->print( out ); 545 544 return out; -
src/SynTree/Expression.h
r28307be r3403534 653 653 }; 654 654 655 std::ostream & operator<<( std::ostream & out, Expression * expr );655 std::ostream & operator<<( std::ostream & out, const Expression * expr ); 656 656 657 657 #endif // EXPRESSION_H -
src/SynTree/FunctionDecl.cc
r28307be r3403534 21 21 #include "Attribute.h" 22 22 #include "Common/utility.h" 23 #include "InitTweak/InitTweak.h" 23 24 24 25 FunctionDecl::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 387 387 } 388 388 389 std::ostream & operator<<( std::ostream & out, Statement * statement ) {389 std::ostream & operator<<( std::ostream & out, const Statement * statement ) { 390 390 statement->print( out ); 391 391 return out; -
src/SynTree/Statement.h
r28307be r3403534 47 47 48 48 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 ); } 49 51 50 52 virtual CompoundStmt *clone() const { return new CompoundStmt( *this ); } … … 395 397 396 398 397 std::ostream & operator<<( std::ostream & out, Statement * statement );399 std::ostream & operator<<( std::ostream & out, const Statement * statement ); 398 400 399 401 #endif // STATEMENT_H -
src/SynTree/Type.cc
r28307be r3403534 84 84 } 85 85 86 std::ostream & operator<<( std::ostream & out, Type * type ) {86 std::ostream & operator<<( std::ostream & out, const Type * type ) { 87 87 type->print( out ); 88 88 return out; -
src/SynTree/Type.h
r28307be r3403534 481 481 } 482 482 483 std::ostream & operator<<( std::ostream & out, Type * type );483 std::ostream & operator<<( std::ostream & out, const Type * type ); 484 484 485 485 #endif // TYPE_H -
src/Tuples/module.mk
r28307be r3403534 15 15 ############################################################################### 16 16 17 SRC += Tuples/Mutate.cc \ 18 Tuples/AssignExpand.cc \ 19 Tuples/FunctionFixer.cc \ 20 Tuples/TupleAssignment.cc \ 21 Tuples/FunctionChecker.cc \ 17 SRC += Tuples/TupleAssignment.cc \ 22 18 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 530 530 return ((int )_retVal0); 531 531 } 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 86 86 __extension__ int __c__i_2; 87 87 }; 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)); 90 89 ((void)__extension__ 3); 91 90 ((void)__extension__ __a__i_1); -
src/tests/.expect/64/gccExtensions.txt
r28307be r3403534 76 76 ((void)((*((int *)(&(*___dst__P2sS_2).__c__i_2)))=__c__i_2) /* ?{} */); 77 77 } 78 int __i__i_2; 79 ((void)((*((int *)(&__i__i_2)))=__extension__ 3) /* ?{} */); 78 int __i__i_2 = ((int )__extension__ 3); 80 79 __extension__ int __a__i_2; 81 80 __extension__ int __b__i_2; … … 133 132 } 134 133 struct s3 __x1__3ss3_2; 135 ((void)___constructor__F_P3ss3_autogen___2(((struct s3 *)(&__x1__3ss3_2))));136 134 struct s3 __y1__3ss3_2; 137 ((void)___constructor__F_P3ss3_autogen___2(((struct s3 *)(&__y1__3ss3_2))));138 135 struct s4 { 139 136 int __i__i_2; … … 141 138 inline struct s4 ___operator_assign__F3ss4_P3ss43ss4_autogen___2(struct s4 *___dst__P3ss4_2, struct s4 ___src__3ss4_2){ 142 139 ((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))));145 140 return ((struct s4 )___src__3ss4_2); 146 141 } … … 158 153 } 159 154 struct s4 __x2__3ss4_2; 160 ((void)___constructor__F_P3ss4_autogen___2(((struct s4 *)(&__x2__3ss4_2))));161 155 struct s4 __y2__3ss4_2; 162 ((void)___constructor__F_P3ss4_autogen___2(((struct s4 *)(&__y2__3ss4_2))));163 156 int __m1__A0i_2[((long unsigned int )10)]; 164 157 int __m2__A0A0i_2[((long unsigned int )10)][((long unsigned int )10)]; … … 166 159 int _retVal0 = { 0 }; 167 160 ((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))));172 161 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))));177 162 } -
src/tests/Makefile.am
r28307be r3403534 62 62 ${CC} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@} 63 63 64 ctorWarnings: ctorWarnings.c65 ${CC} ${CFALGS} - CFA -XCFA -p ${<} -o /dev/null 2>${@}64 memberCtors-ERR1: memberCtors.c 65 ${CC} ${CFALGS} -DERR1 ${<} -o ${@} 66 66 -
src/tests/Makefile.in
r28307be r3403534 670 670 ${CC} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@} 671 671 672 ctorWarnings: ctorWarnings.c673 ${CC} ${CFALGS} - CFA -XCFA -p ${<} -o /dev/null 2>${@}672 memberCtors-ERR1: memberCtors.c 673 ${CC} ${CFALGS} -DERR1 ${<} -o ${@} 674 674 675 675 # Tell versions [3.59,3.63) of GNU make to not export all variables. -
src/tests/test.py
r28307be r3403534 2 2 from __future__ import print_function 3 3 4 from functools import partial 5 from multiprocessing import Pool 4 6 from os import listdir, environ 5 7 from os.path import isfile, join, splitext … … 102 104 # running test functions 103 105 ################################################################################ 104 def run_ test_instance(test, generate, dry_run):106 def run_single_test(test, generate, dry_run): 105 107 106 108 # find the output file based on the test name and options flag … … 163 165 return retcode, error 164 166 167 def 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 165 195 # run the given list of tests with the given parameters 166 196 def run_tests(tests, generate, dry_run, jobs) : … … 174 204 print( "Regenerate tests for: " ) 175 205 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) 207 214 208 215 #clean the workspace 209 216 sh("%s clean > /dev/null 2>&1" % make_cmd, dry_run) 210 217 211 return 1 if failed else 0 218 for failed in results: 219 if failed : 220 return 1 221 222 return 0 212 223 213 224 ################################################################################ … … 279 290 280 291 # 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.jobs292 options.jobs = int(make_max_jobs) if make_max_jobs else (options.jobs if options.jobs else 1) 282 293 if options.jobs <= 0 : 283 294 print('ERROR: Invalid number of jobs', file=sys.stderr) 284 295 sys.exit(1) 285 296 297 print('Running on %i cores' % options.jobs) 298 286 299 # users may want to simply list the tests 287 300 if options.list : -
src/tests/typeof.c
r28307be r3403534 8 8 typeof( int ( int, int p ) ) *v7; 9 9 typeof( [int] ( int, int p ) ) *v8; 10 (typeof(v1)) v2; // cast with typeof 10 11 }
Note: See TracChangeset
for help on using the changeset viewer.