Changeset 56f519b


Ignore:
Timestamp:
Dec 1, 2021, 11:48:34 AM (7 weeks ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
1894e03
Parents:
f27331c
Message:

Clean-up of the last pass. Added a test for the constructor mutex argument test.

Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/KeywordsNew.cpp

    rf27331c r56f519b  
    1010// Created On       : Tue Nov 16  9:53:00 2021
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Nov 30 11:04:00 2021
    13 // Update Count     : 0
     12// Last Modified On : Wed Dec  1 11:24:00 2021
     13// Update Count     : 1
    1414//
    1515
     
    4242        const ast::Stmt * postvisit( const ast::MutexStmt * stmt );
    4343
    44         std::vector<const ast::DeclWithType *> findMutexArgs(
     44        static std::vector<const ast::DeclWithType *> findMutexArgs(
    4545                        const ast::FunctionDecl * decl, bool & first );
    46         void validate( const ast::DeclWithType * decl );
     46        static void validate( const ast::DeclWithType * decl );
     47
    4748        ast::CompoundStmt * addDtorStatements( const ast::FunctionDecl* func, const ast::CompoundStmt *, const std::vector<const ast::DeclWithType *> &);
    4849        ast::CompoundStmt * addStatements( const ast::FunctionDecl* func, const ast::CompoundStmt *, const std::vector<const ast::DeclWithType *> &);
     
    5051        ast::CompoundStmt * addThreadDtorStatements( const ast::FunctionDecl* func, const ast::CompoundStmt * body, const std::vector<const ast::DeclWithType *> & args );
    5152
    52 public:
     53private:
    5354        const ast::StructDecl * monitor_decl = nullptr;
    5455        const ast::StructDecl * guard_decl = nullptr;
     
    9899
    99100        // Monitors can't be constructed with mutual exclusion.
    100         if ( CodeGen::isConstructor( decl->name ) && !is_first_argument_mutex ) {
    101                 SemanticError( decl, "constructors cannot have mutex parameters" );
     101        if ( CodeGen::isConstructor( decl->name ) && is_first_argument_mutex ) {
     102                SemanticError( decl, "constructors cannot have mutex parameters\n" );
    102103        }
    103104
    104105        // It makes no sense to have multiple mutex parameters for the destructor.
    105106        if ( isDtor && mutexArgs.size() != 1 ) {
    106                 SemanticError( decl, "destructors can only have 1 mutex argument" );
     107                SemanticError( decl, "destructors can only have 1 mutex argument\n" );
    107108        }
    108109
     
    172173        for ( auto arg : decl->params ) {
    173174                const ast::Type * type = arg->get_type();
    174                 if ( !type->is_mutex() ) continue;
    175 
    176                 if ( once ) {
    177                         first = true;
    178                         once = false;
     175                if ( type->is_mutex() ) {
     176                        if ( once ) first = true;
     177                        mutexArgs.push_back( arg.get() );
    179178                }
    180 
    181                 mutexArgs.push_back( arg.get() );
     179                once = false;
    182180        }
    183181        return mutexArgs;
  • src/Validate/CompoundLiteral.cpp

    rf27331c r56f519b  
    2727
    2828struct CompoundLiteral final :
    29                 public ast::WithDeclsToAdd<>,
    30                 public ast::WithVisitorRef<CompoundLiteral> {
     29                public ast::WithDeclsToAdd<> {
    3130        ast::Storage::Classes storageClasses;
    3231
     
    4443
    4544        // Transform: [storageClasses] ... (struct S){...} ...
    46         // Into:      [storageClasses] struct S _compLit = {...}; / ... temp ...
     45        // Into:      [storageClasses] struct S _compLit = {...};
     46        //                             ... _compLit ...
    4747        ast::ObjectDecl * temp = new ast::ObjectDecl(
    4848                expr->location,
Note: See TracChangeset for help on using the changeset viewer.