Changeset db4d8e3


Ignore:
Timestamp:
May 29, 2018, 11:51:04 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
71e555c
Parents:
1f81d61
Message:

Fixed issue where constructors who take mutex parameters where not allowed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Keywords.cc

    r1f81d61 rdb4d8e3  
    191191                void postvisit(   StructDecl * decl );
    192192
    193                 std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* );
     193                std::list<DeclarationWithType*> findMutexArgs( FunctionDecl*, bool & first );
    194194                void validate( DeclarationWithType * );
    195195                void addDtorStatments( FunctionDecl* func, CompoundStmt *, const std::list<DeclarationWithType * > &);
     
    441441        void MutexKeyword::postvisit(FunctionDecl* decl) {
    442442
    443                 std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl );
     443                bool first = false;
     444                std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl, first );
    444445                if( mutexArgs.empty() ) return;
    445446
    446                 if( CodeGen::isConstructor(decl->name) ) SemanticError( decl, "constructors cannot have mutex parameters" );
     447                if( CodeGen::isConstructor(decl->name) && first ) SemanticError( decl, "constructors cannot have mutex parameters" );
    447448
    448449                bool isDtor = CodeGen::isDestructor( decl->name );
     
    484485        }
    485486
    486         std::list<DeclarationWithType*> MutexKeyword::findMutexArgs( FunctionDecl* decl ) {
     487        std::list<DeclarationWithType*> MutexKeyword::findMutexArgs( FunctionDecl* decl, bool & first ) {
    487488                std::list<DeclarationWithType*> mutexArgs;
    488489
     490                bool once = true;
    489491                for( auto arg : decl->get_functionType()->get_parameters()) {
    490492                        //Find mutex arguments
    491493                        Type* ty = arg->get_type();
    492494                        if( ! ty->get_mutex() ) continue;
     495
     496                        if(once) {first = true;}
     497                        once = false;
    493498
    494499                        //Append it to the list
Note: See TracChangeset for help on using the changeset viewer.