Changeset 9082d7e8


Ignore:
Timestamp:
Mar 30, 2023, 4:05:59 PM (2 years ago)
Author:
caparson <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
bd72c284
Parents:
d24b1985 (diff), ff443e5 (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 plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
1 added
35 edited

Legend:

Unmodified
Added
Removed
  • Jenkins/Promote

    rd24b1985 r9082d7e8  
    3636                dir (BuildDir) {
    3737                    sh 'rm -rf *'
    38                         sshagent (credentials: ['github_key_jun1']) {
     38                        sshagent (credentials: ['git_key_mar27']) {
    3939                                sh "git clone --bare ${RemoteRepo} repo"
    4040                        }
     
    6969                        sh "git status"
    7070                        sh "git diff-index --quiet HEAD || git commit -m 'Push from build machine: ${name}'"
    71                         sshagent (credentials: ['github_key_jun1']) {
     71                        sshagent (credentials: ['git_key_mar27']) {
    7272                                sh "git push origin master"
    7373                        }
  • libcfa/src/concurrency/pthread.cfa

    rd24b1985 r9082d7e8  
    152152
    153153//######################### Attr helpers #########################
    154 struct cfaPthread_attr_t {                                                              // thread attributes
     154typedef struct cfaPthread_attr_t {                                              // thread attributes
    155155                int contentionscope;
    156156                int detachstate;
     
    160160                int inheritsched;
    161161                struct sched_param param;
    162 } typedef cfaPthread_attr_t;
     162} cfaPthread_attr_t;
    163163
    164164static const cfaPthread_attr_t default_attrs {
  • libcfa/src/interpose.cfa

    rd24b1985 r9082d7e8  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 13 22:39:12 2023
    13 // Update Count     : 193
     12// Last Modified On : Mon Mar 27 21:09:03 2023
     13// Update Count     : 196
    1414//
    1515
     
    4040        union { generic_fptr_t fptr; void * ptr; } originalFunc;
    4141
     42        #if defined( _GNU_SOURCE )
     43        if ( version ) {
     44                originalFunc.ptr = dlvsym( library, symbol, version );
     45        } else {
     46                originalFunc.ptr = dlsym( library, symbol );
     47        } // if
     48        #else
    4249        originalFunc.ptr = dlsym( library, symbol );
    43         if ( ! originalFunc.ptr ) {                                                             // == nullptr
     50        #endif // _GNU_SOURCE
     51
     52        if ( ! originalFunc.ptr ) {                                                     // == nullptr
    4453                abort( "interpose_symbol : internal error, %s\n", dlerror() );
    4554        } // if
     
    4958static generic_fptr_t interpose_symbol( const char symbol[], const char version[] ) {
    5059        void * library;
     60
    5161        #if defined( RTLD_NEXT )
    5262        library = RTLD_NEXT;
  • libcfa/src/interpose_thread.cfa

    rd24b1985 r9082d7e8  
    1414//
    1515
     16// BUG in 32-bit gcc with interpose: fixed in >= gcc-9.5, gcc-10.4, gcc-12.2
    1617#ifdef __i386__                                                                                 // 32-bit architecture
    1718#undef _GNU_SOURCE
     
    3334typedef void (* generic_fptr_t)(void);
    3435
    35 generic_fptr_t interpose_symbol(
     36generic_fptr_t libcfa_public interpose_symbol(
    3637        generic_fptr_t (*do_interpose_symbol)( void * library, const char symbol[], const char version[] ),
    3738        const char symbol[],
    3839        const char version[]
    39 ) libcfa_public {
     40) {
    4041        void * library;
    4142
  • src/AST/ParseNode.hpp

    rd24b1985 r9082d7e8  
    4040        template<typename node_t>
    4141        friend node_t * mutate(const node_t * node);
     42        template<typename node_t>
     43        friend node_t * shallowCopy(const node_t * node);
    4244};
    4345
  • src/CodeGen/CodeGenerator.cc

    rd24b1985 r9082d7e8  
    1717#include <cassert>                   // for assert, assertf
    1818#include <list>                      // for _List_iterator, list, list<>::it...
     19#include <sstream>                   // for stringstream
    1920
    2021#include "AST/Decl.hpp"              // for DeclWithType
    2122#include "Common/UniqueName.h"       // for UniqueName
    22 #include "Common/utility.h"          // for CodeLocation, toString
    2323#include "GenType.h"                 // for genType
    2424#include "InitTweak/InitTweak.h"     // for getPointerBase
  • src/Common/DeclStats.cpp

    rd24b1985 r9082d7e8  
    2323#include <iostream>
    2424#include <map>
     25#include <sstream>
    2526#include <unordered_map>
    2627#include <unordered_set>
  • src/Common/ResolvProtoDump.cpp

    rd24b1985 r9082d7e8  
    1919#include <iostream>
    2020#include <set>
     21#include <sstream>
    2122#include <unordered_set>
    2223
     
    2627#include "AST/Type.hpp"
    2728#include "CodeGen/OperatorTable.h"
    28 #include "Common/utility.h"
    2929
    3030namespace {
  • src/Common/module.mk

    rd24b1985 r9082d7e8  
    5252        Common/Stats/Time.cc \
    5353        Common/Stats/Time.h \
     54        Common/ToString.hpp \
    5455        Common/UniqueName.cc \
    5556        Common/UniqueName.h \
  • src/Common/utility.h

    rd24b1985 r9082d7e8  
    2222#include <list>
    2323#include <memory>
    24 #include <sstream>
    2524#include <string>
    2625#include <type_traits>
     
    143142        dst.swap( src );
    144143}
    145 
    146 template < typename T >
    147 void toString_single( std::ostream & os, const T & value ) {
    148         os << value;
    149 }
    150 
    151 template < typename T, typename... Params >
    152 void toString_single( std::ostream & os, const T & value, const Params & ... params ) {
    153         os << value;
    154         toString_single( os, params ... );
    155 }
    156 
    157 template < typename ... Params >
    158 std::string toString( const Params & ... params ) {
    159         std::ostringstream os;
    160         toString_single( os, params... );
    161         return os.str();
    162 }
    163 
    164 #define toCString( ... ) toString( __VA_ARGS__ ).c_str()
    165144
    166145template< typename... Args >
  • src/ControlStruct/ExceptDeclNew.cpp

    rd24b1985 r9082d7e8  
    1515
    1616#include "ExceptDecl.h"
     17
     18#include <sstream>
    1719
    1820#include "AST/Decl.hpp"
  • src/ControlStruct/MLEMutator.cc

    rd24b1985 r9082d7e8  
    2525#include <memory>                          // for allocator_traits<>::value_...
    2626
    27 #include "Common/utility.h"                // for toString, operator+
     27#include "Common/ToString.hpp"             // for toString
    2828#include "ControlStruct/LabelGenerator.h"  // for LabelGenerator
    2929#include "MLEMutator.h"
  • src/GenPoly/Box.cc

    rd24b1985 r9082d7e8  
    3131#include "Common/SemanticError.h"        // for SemanticError
    3232#include "Common/UniqueName.h"           // for UniqueName
    33 #include "Common/utility.h"              // for toString
     33#include "Common/ToString.hpp"           // for toCString
    3434#include "FindFunction.h"                // for findFunction, findAndReplace...
    3535#include "GenPoly/ErasableScopedMap.h"   // for ErasableScopedMap<>::const_i...
  • src/GenPoly/Lvalue.cc

    rd24b1985 r9082d7e8  
    1717#include <string>                        // for string
    1818
     19#include "Common/ToString.hpp"           // for toCString
    1920#include "Common/UniqueName.h"
    2021#include "Common/PassVisitor.h"
  • src/GenPoly/LvalueNew.cpp

    rd24b1985 r9082d7e8  
    2525#include "AST/Pass.hpp"
    2626#include "Common/SemanticError.h"      // for SemanticWarning
     27#include "Common/ToString.hpp"         // for toCString
    2728#include "Common/UniqueName.h"         // for UniqueName
    2829#include "GenPoly/GenPoly.h"           // for genFunctionType
  • src/InitTweak/FixInit.cc

    rd24b1985 r9082d7e8  
    3232#include "Common/PassVisitor.h"        // for PassVisitor, WithStmtsToAdd
    3333#include "Common/SemanticError.h"      // for SemanticError
     34#include "Common/ToString.hpp"         // for toCString
    3435#include "Common/UniqueName.h"         // for UniqueName
    35 #include "Common/utility.h"            // for CodeLocation, ValueGuard, toSt...
    3636#include "FixGlobalInit.h"             // for fixGlobalInit
    3737#include "GenInit.h"                   // for genCtorDtor
  • src/InitTweak/FixInitNew.cpp

    rd24b1985 r9082d7e8  
    2020#include "Common/PassVisitor.h"        // for PassVisitor, WithStmtsToAdd
    2121#include "Common/SemanticError.h"      // for SemanticError
     22#include "Common/ToString.hpp"         // for toCString
    2223#include "Common/UniqueName.h"         // for UniqueName
    23 #include "Common/utility.h"            // for CodeLocation, ValueGuard, toSt...
    2424#include "FixGlobalInit.h"             // for fixGlobalInit
    2525#include "GenInit.h"                   // for genCtorDtor
  • src/InitTweak/GenInit.cc

    rd24b1985 r9082d7e8  
    3131#include "Common/PassVisitor.h"        // for PassVisitor, WithGuards, WithShort...
    3232#include "Common/SemanticError.h"      // for SemanticError
     33#include "Common/ToString.hpp"         // for toCString
    3334#include "Common/UniqueName.h"         // for UniqueName
    3435#include "Common/utility.h"            // for ValueGuard, maybeClone
  • src/Parser/ParseNode.h

    rd24b1985 r9082d7e8  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Feb 19 09:02:37 2023
    13 // Update Count     : 940
     12// Last Modified On : Wed Mar 29 08:40:27 2023
     13// Update Count     : 948
    1414//
    1515
     
    425425Statement * build_directive( std::string * directive );
    426426SuspendStmt * build_suspend( StatementNode *, SuspendStmt::Type = SuspendStmt::None);
    427 WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when );
    428 WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when, WaitForStmt * existing );
    429 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when );
    430 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when, StatementNode * else_stmt, ExpressionNode * else_when );
     427WaitForStmt * build_waitfor( WaitForStmt * existing, ExpressionNode * when, ExpressionNode * targetExpr, StatementNode * stmt );
     428WaitForStmt * build_waitfor_else( WaitForStmt * existing, ExpressionNode * when, StatementNode * stmt );
     429WaitForStmt * build_waitfor_timeout( WaitForStmt * existing, ExpressionNode * when, ExpressionNode * timeout, StatementNode * stmt );
    431430Statement * build_with( ExpressionNode * exprs, StatementNode * stmt );
    432431Statement * build_mutex( ExpressionNode * exprs, StatementNode * stmt );
  • src/Parser/StatementNode.cc

    rd24b1985 r9082d7e8  
    1111// Created On       : Sat May 16 14:59:41 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Wed Feb  2 20:29:30 2022
    14 // Update Count     : 425
     13// Last Modified On : Wed Mar 29 08:51:23 2023
     14// Update Count     : 454
    1515//
    1616
     
    268268
    269269        return node;
    270 }
    271 
    272 WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when ) {
    273         auto node = new WaitForStmt();
    274 
     270} // build_suspend
     271
     272WaitForStmt * build_waitfor( WaitForStmt * existing, ExpressionNode * when, ExpressionNode * targetExpr, StatementNode * stmt ) {
    275273        WaitForStmt::Target target;
    276274        target.function = maybeBuild( targetExpr );
     
    282280        delete targetExpr;
    283281
    284         node->clauses.push_back( WaitForStmt::Clause{
    285                 target,
    286                 maybeMoveBuild( stmt ),
    287                 notZeroExpr( maybeMoveBuild( when ) )
    288         });
    289 
    290         return node;
    291 } // build_waitfor
    292 
    293 WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when, WaitForStmt * node ) {
    294         WaitForStmt::Target target;
    295         target.function = maybeBuild( targetExpr );
    296 
    297         ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() );
    298         targetExpr->set_next( nullptr );
    299         buildMoveList< Expression >( next, target.arguments );
    300 
    301         delete targetExpr;
    302 
    303         node->clauses.insert( node->clauses.begin(), WaitForStmt::Clause{
     282        existing->clauses.insert( existing->clauses.begin(), WaitForStmt::Clause{
    304283                std::move( target ),
    305284                maybeMoveBuild( stmt ),
     
    307286        });
    308287
    309         return node;
     288        return existing;
    310289} // build_waitfor
    311290
    312 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when ) {
    313         auto node = new WaitForStmt();
    314 
    315         if( timeout ) {
    316                 node->timeout.time      = maybeMoveBuild( timeout );
    317                 node->timeout.statement = maybeMoveBuild( stmt    );
    318                 node->timeout.condition = notZeroExpr( maybeMoveBuild( when ) );
    319         } else {
    320                 node->orelse.statement  = maybeMoveBuild( stmt );
    321                 node->orelse.condition  = notZeroExpr( maybeMoveBuild( when ) );
    322         } // if
    323 
    324         return node;
    325 } // build_waitfor_timeout
    326 
    327 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when,  StatementNode * else_, ExpressionNode * else_when ) {
    328         auto node = new WaitForStmt();
    329 
    330         node->timeout.time      = maybeMoveBuild( timeout );
    331         node->timeout.statement = maybeMoveBuild( stmt    );
    332         node->timeout.condition = notZeroExpr( maybeMoveBuild( when ) );
    333 
    334         node->orelse.statement  = maybeMoveBuild( else_ );
    335         node->orelse.condition  = notZeroExpr( maybeMoveBuild( else_when ) );
    336 
    337         return node;
     291WaitForStmt * build_waitfor_else( WaitForStmt * existing, ExpressionNode * when, StatementNode * stmt ) {
     292        existing->orelse.statement  = maybeMoveBuild( stmt );
     293        existing->orelse.condition  = notZeroExpr( maybeMoveBuild( when ) );
     294
     295        return existing;
     296} // build_waitfor_else
     297
     298WaitForStmt * build_waitfor_timeout( WaitForStmt * existing, ExpressionNode * when, ExpressionNode * timeout, StatementNode * stmt ) {
     299        existing->timeout.time      = maybeMoveBuild( timeout );
     300        existing->timeout.statement = maybeMoveBuild( stmt );
     301        existing->timeout.condition = notZeroExpr( maybeMoveBuild( when ) );
     302
     303        return existing;
    338304} // build_waitfor_timeout
    339305
  • src/Parser/lex.ll

    rd24b1985 r9082d7e8  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Mon Jan 30 19:03:34 2023
    13  * Update Count     : 767
     12 * Last Modified On : Sat Mar 25 08:09:03 2023
     13 * Update Count     : 768
    1414 */
    1515
     
    214214__alignof               { KEYWORD_RETURN(ALIGNOF); }                    // GCC
    215215__alignof__             { KEYWORD_RETURN(ALIGNOF); }                    // GCC
     216and                             { QKEYWORD_RETURN(WAND); }                              // CFA
    216217asm                             { KEYWORD_RETURN(ASM); }
    217218__asm                   { KEYWORD_RETURN(ASM); }                                // GCC
  • src/Parser/parser.yy

    rd24b1985 r9082d7e8  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar 22 21:26:01 2023
    13 // Update Count     : 6002
     12// Last Modified On : Wed Mar 29 17:56:42 2023
     13// Update Count     : 6325
    1414//
    1515
     
    4444
    4545#include <cstdio>
     46#include <sstream>
    4647#include <stack>
    4748using namespace std;
     
    270271        SemanticError( yylloc, ::toString( "Identifier \"", identifier, "\" cannot appear before a ", kind, ".\n"
    271272                                   "Possible cause is misspelled storage/CV qualifier, misspelled typename, or missing generic parameter." ) );
    272 } // IdentifierBeforeType
    273 
    274 static bool TypedefForall( DeclarationNode * decl ) {
    275         if ( decl->type->forall || (decl->type->kind == TypeData::Aggregate && decl->type->aggregate.params) ) {
    276                 SemanticError( yylloc, "forall qualifier in typedef is currently unimplemented." );
    277                 return true;
    278         } // if
    279         return false;
    280273} // IdentifierBeforeType
    281274
     
    359352
    360353// names and constants: lexer differentiates between identifier and typedef names
    361 %token<tok> IDENTIFIER          QUOTED_IDENTIFIER       TYPEDIMname             TYPEDEFname             TYPEGENname
    362 %token<tok> TIMEOUT                     WOR                                     CATCH                   RECOVER                 CATCHRESUME             FIXUP           FINALLY         // CFA
     354%token<tok> IDENTIFIER          TYPEDIMname             TYPEDEFname             TYPEGENname
     355%token<tok> TIMEOUT                     WAND    WOR                     CATCH                   RECOVER                 CATCHRESUME             FIXUP           FINALLY         // CFA
    363356%token<tok> INTEGERconstant     CHARACTERconstant       STRINGliteral
    364357%token<tok> DIRECTIVE
     
    429422%type<catch_kind> handler_key
    430423%type<sn> mutex_statement
    431 %type<en> when_clause                                   when_clause_opt                         waitfor                                         timeout
    432 %type<sn> waitfor_statement
    433 %type<wfs> waitfor_clause
     424%type<en> when_clause                                   when_clause_opt                         waitfor         waituntil               timeout
     425%type<sn> waitfor_statement                             waituntil_statement
     426%type<wfs> wor_waitfor_clause                   waituntil_clause                        wand_waituntil_clause   wor_waituntil_clause
    434427
    435428// declarations
     
    535528// Similar issues exit with the waitfor statement.
    536529
    537 // Order of these lines matters (low-to-high precedence). THEN is left associative over WOR/TIMEOUT/ELSE, WOR is left
    538 // associative over TIMEOUT/ELSE, and TIMEOUT is left associative over ELSE.
     530// Order of these lines matters (low-to-high precedence). THEN is left associative over WAND/WOR/TIMEOUT/ELSE, WAND/WOR
     531// is left associative over TIMEOUT/ELSE, and TIMEOUT is left associative over ELSE.
    539532%precedence THEN                // rule precedence for IF/WAITFOR statement
     533%precedence ANDAND              // token precedence for start of WAND in WAITFOR statement
     534%precedence WAND                // token precedence for start of WAND in WAITFOR statement
     535%precedence OROR                // token precedence for start of WOR in WAITFOR statement
    540536%precedence WOR                 // token precedence for start of WOR in WAITFOR statement
    541537%precedence TIMEOUT             // token precedence for start of TIMEOUT in WAITFOR statement
     
    624620quasi_keyword:                                                                                  // CFA
    625621        TIMEOUT
     622        | WAND
    626623        | WOR
    627624        | CATCH
     
    774771                { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); }
    775772        | postfix_expression ICR
    776                 { $$ = new ExpressionNode( build_unary_val( OperKinds::IncrPost, $1 ) ); }
     773                { $$ = new ExpressionNode( build_unary_val( OperKinds::IncrPost, $1 ) ); }
    777774        | postfix_expression DECR
    778                 { $$ = new ExpressionNode( build_unary_val( OperKinds::DecrPost, $1 ) ); }
     775                { $$ = new ExpressionNode( build_unary_val( OperKinds::DecrPost, $1 ) ); }
    779776        | '(' type_no_function ')' '{' initializer_list_opt comma_opt '}' // C99, compound-literal
    780777                { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); }
     
    804801        '@'                                                                                                     // CFA, default parameter
    805802                { SemanticError( yylloc, "Default parameter for argument is currently unimplemented." ); $$ = nullptr; }
    806                 // { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); }
     803                // { $$ = new ExpressionNode( build_constantInteger( *new string( "2" ) ) ); }
    807804        | assignment_expression
    808805        ;
     
    879876                }
    880877        | unary_operator cast_expression
    881                 { $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); }
     878                { $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); }
    882879        | ICR unary_expression
    883                 { $$ = new ExpressionNode( build_unary_val( OperKinds::Incr, $2 ) ); }
     880                { $$ = new ExpressionNode( build_unary_val( OperKinds::Incr, $2 ) ); }
    884881        | DECR unary_expression
    885                 { $$ = new ExpressionNode( build_unary_val( OperKinds::Decr, $2 ) ); }
     882                { $$ = new ExpressionNode( build_unary_val( OperKinds::Decr, $2 ) ); }
    886883        | SIZEOF unary_expression
    887884                { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuild( $2 ) ) ); }
     
    11361133        | mutex_statement
    11371134        | waitfor_statement
     1135        | waituntil_statement
    11381136        | exception_statement
    11391137        | enable_disable_statement
     
    12451243        | declaration comma_expression                                          // semi-colon separated
    12461244                { $$ = new CondCtl( $1, $2 ); }
    1247         ;
     1245        ;
    12481246
    12491247// CASE and DEFAULT clauses are only allowed in the SWITCH statement, precluding Duff's device. In addition, a case
     
    13281326                }
    13291327        | FOR '(' for_control_expression_list ')' statement     %prec THEN
    1330                 { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }
     1328                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }
    13311329        | FOR '(' for_control_expression_list ')' statement ELSE statement // CFA
    13321330                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ), $7 ) ); }
     
    15201518                        SemanticError( yylloc, "Type iterator is currently unimplemented." ); $$ = nullptr;
    15211519                }
    1522         ;
     1520        ;
    15231521
    15241522downupdowneq:
     
    15291527        | ErangeDownEq
    15301528                { $$ = OperKinds::GEThan; }
    1531         ;
     1529        ;
    15321530
    15331531updown:
     
    15361534        | ErangeDown
    15371535                { $$ = OperKinds::GThan; }
    1538         ;
     1536        ;
    15391537
    15401538updowneq:
     
    15441542        | ErangeDownEq
    15451543                { $$ = OperKinds::GEThan; }
    1546         ;
     1544        ;
    15471545
    15481546jump_statement:
     
    16271625        ;
    16281626
    1629 waitfor:
    1630         WAITFOR '(' cast_expression ')'
    1631                 { $$ = $3; }
    1632 //      | WAITFOR '(' cast_expression ',' argument_expression_list_opt ')'
    1633 //              { $$ = (ExpressionNode *)$3->set_last( $5 ); }
    1634         | WAITFOR '(' cast_expression_list ':' argument_expression_list_opt ')'
    1635                 { $$ = (ExpressionNode *)($3->set_last( $5 )); }
    1636         ;
    1637 
    16381627cast_expression_list:
    16391628        cast_expression
     
    16441633
    16451634timeout:
    1646         TIMEOUT '(' comma_expression ')'                        { $$ = $3; }
    1647         ;
    1648 
    1649 waitfor_clause:
     1635        TIMEOUT '(' comma_expression ')'                        { $$ = $3; }
     1636        ;
     1637
     1638wor:
     1639        OROR
     1640        | WOR
     1641
     1642waitfor:
     1643        WAITFOR '(' cast_expression ')'
     1644                { $$ = $3; }
     1645        | WAITFOR '(' cast_expression_list ':' argument_expression_list_opt ')'
     1646                { $$ = (ExpressionNode *)($3->set_last( $5 )); }
     1647        ;
     1648
     1649wor_waitfor_clause:
    16501650        when_clause_opt waitfor statement                                       %prec THEN
    1651                 { $$ = build_waitfor( $2, maybe_build_compound( $3 ), $1 ); }
    1652         | when_clause_opt waitfor statement WOR waitfor_clause
    1653                 { $$ = build_waitfor( $2, maybe_build_compound( $3 ), $1, $5 ); }
    1654         | when_clause_opt timeout statement                                     %prec THEN
    1655                 { $$ = build_waitfor_timeout( $2, maybe_build_compound( $3 ), $1 ); }
    1656         | when_clause_opt ELSE statement
    1657                 { $$ = build_waitfor_timeout( nullptr, maybe_build_compound( $3 ), $1 ); }
     1651                // Called first: create header for WaitForStmt.
     1652                { $$ = build_waitfor( new WaitForStmt(), $1, $2, maybe_build_compound( $3 ) ); }
     1653        | wor_waitfor_clause wor when_clause_opt waitfor statement      %prec THEN
     1654                { $$ = build_waitfor( $1, $3, $4, maybe_build_compound( $5 ) ); }
     1655        | wor_waitfor_clause wor when_clause_opt ELSE statement
     1656                { $$ = build_waitfor_else( $1, $3, maybe_build_compound( $5 ) ); }
     1657        | wor_waitfor_clause wor when_clause_opt timeout statement      %prec THEN
     1658                { $$ = build_waitfor_timeout( $1, $3, $4, maybe_build_compound( $5 ) ); }
    16581659        // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)
    1659         | when_clause_opt timeout statement WOR ELSE statement // syntax error
     1660        | wor_waitfor_clause wor when_clause_opt timeout statement wor ELSE statement // syntax error
    16601661                { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; }
    1661         | when_clause_opt timeout statement WOR when_clause ELSE statement
    1662                 { $$ = build_waitfor_timeout( $2, maybe_build_compound( $3 ), $1, maybe_build_compound( $7 ), $5 ); }
    1663         ;
     1662        | wor_waitfor_clause wor when_clause_opt timeout statement wor when_clause ELSE statement
     1663                { $$ = build_waitfor_else( build_waitfor_timeout( $1, $3, $4, maybe_build_compound( $5 ) ), $7, maybe_build_compound( $9 ) ); }
    16641664
    16651665waitfor_statement:
    1666         when_clause_opt waitfor statement                                       %prec THEN
    1667                 { $$ = new StatementNode( build_waitfor( $2, $3, $1 ) ); }
    1668         | when_clause_opt waitfor statement WOR waitfor_clause
    1669                 { $$ = new StatementNode( build_waitfor( $2, $3, $1, $5 ) ); }
     1666        wor_waitfor_clause                                                                      %prec THEN
     1667                { $$ = new StatementNode( $1 ); }
     1668        ;
     1669
     1670wand:
     1671        ANDAND
     1672        | WAND
     1673        ;
     1674
     1675waituntil:
     1676        WAITUNTIL '(' cast_expression ')'
     1677                { $$ = $3; }
     1678        ;
     1679
     1680waituntil_clause:
     1681        when_clause_opt waituntil statement
     1682                { printf( "waituntil_clause 1\n" ); $$ = nullptr; }
     1683        | '(' wor_waituntil_clause ')'
     1684                { printf( "waituntil_clause 2\n" ); $$ = nullptr; }
     1685        ;
     1686
     1687wand_waituntil_clause:
     1688        waituntil_clause                                                                        %prec THEN
     1689                { printf( "wand_waituntil_clause 1\n" ); $$ = nullptr; }
     1690        | waituntil_clause wand wand_waituntil_clause
     1691                { printf( "wand_waituntil_clause 2\n" ); $$ = nullptr; }
     1692        ;
     1693
     1694wor_waituntil_clause:
     1695        wand_waituntil_clause
     1696                { printf( "wor_waituntil_clause 1\n" ); $$ = nullptr; }
     1697        | wor_waituntil_clause wor wor_waituntil_clause         %prec THEN
     1698                { printf( "wor_waituntil_clause 2\n" ); $$ = nullptr; }
     1699        | wor_waituntil_clause wor when_clause_opt ELSE statement
     1700                { printf( "wor_waituntil_clause 3\n" ); $$ = nullptr; }
     1701        | wor_waituntil_clause wor when_clause_opt timeout statement    %prec THEN
     1702                { printf( "wor_waituntil_clause 4\n" ); $$ = nullptr; }
     1703        // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)
     1704        | wor_waituntil_clause wor when_clause_opt timeout statement wor ELSE statement // syntax error
     1705                { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; }
     1706        | wor_waituntil_clause wor when_clause_opt timeout statement wor when_clause ELSE statement
     1707                { printf( "wor_waituntil_clause 6\n" ); $$ = nullptr; }
     1708        ;
     1709
     1710waituntil_statement:
     1711        wor_waituntil_clause                                                            %prec THEN
     1712                // SKULLDUGGERY: create an empty compound statement to test parsing of waituntil statement.
     1713                { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); }
    16701714        ;
    16711715
    16721716exception_statement:
    1673         TRY compound_statement handler_clause                                   %prec THEN
     1717        TRY compound_statement handler_clause                           %prec THEN
    16741718                { $$ = new StatementNode( build_try( $2, $3, nullptr ) ); }
    16751719        | TRY compound_statement finally_clause
     
    18311875                {
    18321876                        // printf( "C_DECLARATION1 %p %s\n", $$, $$->name ? $$->name->c_str() : "(nil)" );
    1833                         // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     1877                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
    18341878                        //   printf( "\tattr %s\n", attr->name.c_str() );
    18351879                        // } // for
     
    19672011                {
    19682012                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" );
    1969                         if ( TypedefForall( $2 ) ) $$ = nullptr;
    1970                         else $$ = $3->addType( $2 )->addTypedef();              // watchout frees $2 and $3
     2013                        if ( $2->type->forall || ($2->type->kind == TypeData::Aggregate && $2->type->aggregate.params) ) {
     2014                                SemanticError( yylloc, "forall qualifier in typedef is currently unimplemented." ); $$ = nullptr;
     2015                        } else $$ = $3->addType( $2 )->addTypedef(); // watchout frees $2 and $3
    19712016                }
    19722017        | typedef_declaration pop ',' push declarator
     
    19762021                }
    19772022        | type_qualifier_list TYPEDEF type_specifier declarator // remaining OBSOLESCENT (see 2 )
    1978                 {
    1979                         typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "6" );
    1980                         if ( TypedefForall( $1 ) ) $$ = nullptr;
    1981                         else $$ = $4->addQualifiers( $1 )->addType( $3 )->addTypedef();
    1982                 }
     2023                { SemanticError( yylloc, "Type qualifiers/specifiers before TYPEDEF is deprecated, move after TYPEDEF." ); $$ = nullptr; }
    19832024        | type_specifier TYPEDEF declarator
    1984                 {
    1985                         typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "7" );
    1986                         if ( TypedefForall( $1 ) ) $$ = nullptr;
    1987                         else $$ = $3->addType( $1 )->addTypedef();
    1988                 }
     2025                { SemanticError( yylloc, "Type qualifiers/specifiers before TYPEDEF is deprecated, move after TYPEDEF." ); $$ = nullptr; }
    19892026        | type_specifier TYPEDEF type_qualifier_list declarator
    1990                 {
    1991                         typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "8" );
    1992                         if ( TypedefForall( $3 ) ) $$ = nullptr;
    1993                         else $$ = $4->addQualifiers( $1 )->addType( $1 )->addTypedef();
    1994                 }
     2027                { SemanticError( yylloc, "Type qualifiers/specifiers before TYPEDEF is deprecated, move after TYPEDEF." ); $$ = nullptr; }
    19952028        ;
    19962029
     
    19992032        TYPEDEF identifier '=' assignment_expression
    20002033                {
    2001                         SemanticError( yylloc, "Typedef expression is deprecated, use typeof(...) instead." ); $$ = nullptr;
     2034                        SemanticError( yylloc, "TYPEDEF expression is deprecated, use typeof(...) instead." ); $$ = nullptr;
    20022035                }
    20032036        | typedef_expression pop ',' push identifier '=' assignment_expression
    20042037                {
    2005                         SemanticError( yylloc, "Typedef expression is deprecated, use typeof(...) instead." ); $$ = nullptr;
     2038                        SemanticError( yylloc, "TYPEDEF expression is deprecated, use typeof(...) instead." ); $$ = nullptr;
    20062039                }
    20072040        ;
     
    23012334                {
    23022335                        // printf( "sue_declaration_specifier %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
    2303                         // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     2336                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
    23042337                        //   printf( "\tattr %s\n", attr->name.c_str() );
    23052338                        // } // for
     
    23172350                {
    23182351                        // printf( "sue_type_specifier %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
    2319                         // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     2352                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
    23202353                        //   printf( "\tattr %s\n", attr->name.c_str() );
    23212354                        // } // for
     
    23952428                {
    23962429                        // printf( "elaborated_type %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
    2397                         // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     2430                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
    23982431                        //   printf( "\tattr %s\n", attr->name.c_str() );
    23992432                        // } // for
     
    25222555                        $$ = fieldDecl( $1, $2 );
    25232556                        // printf( "type_specifier2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
    2524                         // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
     2557                        // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
    25252558                        //   printf( "\tattr %s\n", attr->name.c_str() );
    25262559                        // } // for
     
    25292562                { $$ = fieldDecl( $2, $3 ); distExt( $$ ); }
    25302563        | STATIC type_specifier field_declaring_list_opt ';' // CFA
    2531                 { SemanticError( yylloc, "STATIC aggregate field qualifier currently unimplemented." ); $$ = nullptr; }
     2564                { SemanticError( yylloc, "STATIC aggregate field qualifier currently unimplemented." ); $$ = nullptr; }
    25322565        | INLINE type_specifier field_abstract_list_opt ';'     // CFA
    25332566                {
     
    25402573                }
    25412574        | INLINE aggregate_control ';'                                          // CFA
    2542                 { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }
     2575                { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }
    25432576        | typedef_declaration ';'                                                       // CFA
    25442577        | cfa_field_declaring_list ';'                                          // CFA, new style field declaration
     
    26232656                { $$ = DeclarationNode::newEnum( $3->name, $6, true, false, nullptr, $4 )->addQualifiers( $2 ); }
    26242657        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    2625                 {
     2658                {
    26262659                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.any() )
    26272660                        { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
     
    31573190                {
    31583191                        distQual( $5, $1 );
    3159                         forall = false;
     3192                        forall = false;
    31603193                        $$ = $5;
    31613194                }
     
    31683201                {
    31693202                        distQual( $5, $1 );
    3170                         forall = false;
     3203                        forall = false;
    31713204                        $$ = $5;
    31723205                }
     
    31793212                {
    31803213                        distQual( $6, $1->addQualifiers( $2 ) );
    3181                         forall = false;
     3214                        forall = false;
    31823215                        $$ = $6;
    31833216                }
     
    33863419        | '(' attribute_list variable_ptr ')' array_dimension
    33873420                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    3388         | '(' variable_array ')' multi_array_dimension          // redundant parenthesis
     3421        | '(' variable_array ')' multi_array_dimension          // redundant parenthesis
    33893422                { $$ = $2->addArray( $4 ); }
    33903423        | '(' attribute_list variable_array ')' multi_array_dimension // redundant parenthesis
     
    38093842        | ErangeUpEq
    38103843                { $$ = OperKinds::LEThan; }
    3811         ;
     3844        ;
    38123845
    38133846multi_array_dimension:
  • src/ResolvExpr/Candidate.cpp

    rd24b1985 r9082d7e8  
    1717
    1818#include <iostream>
     19#include <sstream>
    1920
    2021#include "AST/Print.hpp"
     
    4445        sorted.reserve(cands.size());
    4546        for(const auto & c : cands) {
    46                 std::stringstream ss;
     47                std::ostringstream ss;
    4748                print( ss, *c, indent );
    4849                sorted.push_back(ss.str());
  • src/ResolvExpr/Resolver.cc

    rd24b1985 r9082d7e8  
    3939#include "AST/Type.hpp"
    4040#include "Common/Eval.h"                 // for eval
     41#include "Common/Iterate.hpp"            // for group_iterate
    4142#include "Common/PassVisitor.h"          // for PassVisitor
    4243#include "Common/SemanticError.h"        // for SemanticError
    4344#include "Common/Stats/ResolveTime.h"    // for ResolveTime::start(), ResolveTime::stop()
    44 #include "Common/utility.h"              // for ValueGuard, group_iterate
     45#include "Common/ToString.hpp"           // for toCString
    4546#include "InitTweak/GenInit.h"
    4647#include "InitTweak/InitTweak.h"         // for isIntrinsicSingleArgCallStmt
  • src/SymTab/FixFunction.cc

    rd24b1985 r9082d7e8  
    2121#include "AST/Pass.hpp"
    2222#include "AST/Type.hpp"
    23 #include "Common/utility.h"       // for maybeClone, copy
     23#include "Common/utility.h"       // for copy
    2424#include "SynTree/Declaration.h"  // for FunctionDecl, ObjectDecl, Declarati...
    2525#include "SynTree/Expression.h"   // for Expression
  • src/SymTab/Mangler.cc

    rd24b1985 r9082d7e8  
    2424#include "CodeGen/OperatorTable.h"       // for OperatorInfo, operatorLookup
    2525#include "Common/PassVisitor.h"
     26#include "Common/ToString.hpp"           // for toCString
    2627#include "Common/SemanticError.h"        // for SemanticError
    27 #include "Common/utility.h"              // for toString
    2828#include "ResolvExpr/TypeEnvironment.h"  // for TypeEnvironment
    2929#include "SynTree/LinkageSpec.h"         // for Spec, isOverridable, AutoGen, Int...
  • src/SymTab/Validate.cc

    rd24b1985 r9082d7e8  
    5555#include "Common/ScopedMap.h"          // for ScopedMap
    5656#include "Common/SemanticError.h"      // for SemanticError
     57#include "Common/ToString.hpp"         // for toCString
    5758#include "Common/UniqueName.h"         // for UniqueName
    58 #include "Common/utility.h"            // for operator+, cloneAll, deleteAll
     59#include "Common/utility.h"            // for cloneAll, deleteAll
    5960#include "CompilationState.h"          // skip some passes in new-ast build
    6061#include "Concurrency/Keywords.h"      // for applyKeywords
  • src/SymTab/ValidateType.cc

    rd24b1985 r9082d7e8  
    1818#include "CodeGen/OperatorTable.h"
    1919#include "Common/PassVisitor.h"
     20#include "Common/ToString.hpp"
    2021#include "SymTab/FixFunction.h"
    2122#include "SynTree/Declaration.h"
  • src/SynTree/Type.cc

    rd24b1985 r9082d7e8  
    1616
    1717#include "Attribute.h"                // for Attribute
     18#include "Common/ToString.hpp"        // for toCString
    1819#include "Common/utility.h"           // for cloneAll, deleteAll, printAll
    1920#include "InitTweak/InitTweak.h"      // for getPointerBase
     
    105106int Type::referenceDepth() const { return 0; }
    106107
     108AggregateDecl * Type::getAggr() const {
     109        assertf( false, "Non-aggregate type: %s", toCString( this ) );
     110}
     111
    107112TypeSubstitution Type::genericSubstitution() const { assertf( false, "Non-aggregate type: %s", toCString( this ) ); }
    108113
  • src/SynTree/Type.h

    rd24b1985 r9082d7e8  
    2424#include "BaseSyntaxNode.h"  // for BaseSyntaxNode
    2525#include "Common/Iterate.hpp"// for operator+
    26 #include "Common/utility.h"  // for toCString
    2726#include "Mutator.h"         // for Mutator
    2827#include "SynTree.h"         // for AST nodes
     
    186185        virtual bool isComplete() const { return true; }
    187186
    188         virtual AggregateDecl * getAggr() const { assertf( false, "Non-aggregate type: %s", toCString( this ) ); }
     187        virtual AggregateDecl * getAggr() const;
    189188
    190189        virtual TypeSubstitution genericSubstitution() const;
  • src/Validate/FixQualifiedTypes.cpp

    rd24b1985 r9082d7e8  
    1616#include "Validate/FixQualifiedTypes.hpp"
    1717
     18#include "AST/LinkageSpec.hpp"             // for Linkage
    1819#include "AST/Pass.hpp"
    1920#include "AST/TranslationUnit.hpp"
     21#include "Common/ToString.hpp"             // for toString
     22#include "SymTab/Mangler.h"                // for Mangler
    2023#include "Validate/NoIdSymbolTable.hpp"
    21 #include "SymTab/Mangler.h"            // for Mangler
    22 #include "AST/LinkageSpec.hpp"                     // for Linkage
    2324
    2425namespace Validate {
  • src/Validate/ForallPointerDecay.cpp

    rd24b1985 r9082d7e8  
    2222#include "CodeGen/OperatorTable.h"
    2323#include "Common/CodeLocation.h"
     24#include "Common/ToString.hpp"
    2425#include "SymTab/FixFunction.h"
    2526
  • src/Validate/HandleAttributes.cc

    rd24b1985 r9082d7e8  
    1919#include "Common/Eval.h"
    2020#include "Common/PassVisitor.h"
     21#include "Common/ToString.hpp"
    2122#include "Common/SemanticError.h"
    2223#include "ResolvExpr/Resolver.h"
  • src/Validate/HoistStruct.cpp

    rd24b1985 r9082d7e8  
    1616#include "Validate/HoistStruct.hpp"
    1717
     18#include <sstream>
     19
    1820#include "AST/Pass.hpp"
    1921#include "AST/TranslationUnit.hpp"
    20 #include "Common/utility.h"
    2122
    2223namespace Validate {
  • src/include/cassert

    rd24b1985 r9082d7e8  
    2020#include_next <cassert>
    2121
    22 #include <string>
    23 
    24 template < typename ... Params >
    25 std::string toString( const Params & ... params );
     22#include "Common/ToString.hpp"
    2623
    2724#ifdef NDEBUG
Note: See TracChangeset for help on using the changeset viewer.