Changeset ad47ec4 for src/Parser


Ignore:
Timestamp:
Aug 29, 2024, 2:38:39 PM (14 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
9bb6c5f
Parents:
960665c (diff), b965774 (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

Location:
src/Parser
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cpp

    r960665c rad47ec4  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb 23 18:25:57 2024
    13 // Update Count     : 1533
     12// Last Modified On : Thu Aug 22 14:11:47 2024
     13// Update Count     : 1555
    1414//
    1515
     
    134134                os << endl << string( indent + 2, ' ' ) << "with initializer ";
    135135                initializer->printOneLine( os );
    136                 os << " maybe constructed? " << initializer->get_maybeConstructed();
     136                if ( ! initializer->get_maybeConstructed() ) {
     137                        os << " constructed with @= ";
     138                } // if
    137139        } // if
    138140
     
    957959                        isDelete ? nullptr : maybeBuild( initializer ),
    958960                        copy( attributes )
    959                 )->set_extension( extension );
     961                );
     962                decl->extension = extension;
    960963                if ( isDelete ) {
    961964                        auto dwt = strict_dynamic_cast<ast::DeclWithType *>( decl );
     
    9991002        assert( type );
    10001003
    1001         // Some types are parsed as declarations and, syntactically, can have
    1002         // initializers. However, semantically, this is meaningless.
    1003         if ( initializer ) {
    1004                 SemanticError( this, "Initializer on type declaration " );
     1004        // Some types are parsed as declarations and, syntactically, can have initializers, which are not support (possibly
     1005        // meaningless).
     1006        if ( initializer && initializer->get_maybeConstructed() ) { // no @=
     1007                SemanticError( location, "default initialization for parameter %s is unsupport for a function-pointer declaration.",
     1008                                           (this->name) ? this->name->c_str() : "anonymous" );
    10051009        }
    10061010
  • src/Parser/ExpressionNode.cpp

    r960665c rad47ec4  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat May 16 13:17:07 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec 14 18:57:07 2023
    13 // Update Count     : 1087
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Aug 23 10:22:00 2024
     13// Update Count     : 1088
    1414//
    1515
     
    780780} // build_compoundLiteral
    781781
     782ast::Expr * build_va_arg( const CodeLocation & location,
     783                ExpressionNode * function, DeclarationNode * declaration ) {
     784        return build_func( location,
     785                new ExpressionNode(
     786                        build_varref( location, new std::string( "__builtin_va_arg" ) ) ),
     787                function->set_last( new ExpressionNode( new ast::TypeExpr( location,
     788                        maybeMoveBuildType( declaration ) ) ) )
     789        );
     790}
     791
    782792// Local Variables: //
    783793// tab-width: 4 //
  • src/Parser/ExpressionNode.hpp

    r960665c rad47ec4  
    4343        ast::Expr * build() {
    4444                ast::Expr * node = expr.release();
    45                 node->set_extension( this->get_extension() );
     45                node->extension = this->extension;
    4646                node->location = this->location;
    4747                return node;
     
    8383ast::Expr * build_func( const CodeLocation &, ExpressionNode * function, ExpressionNode * expr_node );
    8484ast::Expr * build_compoundLiteral( const CodeLocation &, DeclarationNode * decl_node, InitializerNode * kids );
     85ast::Expr * build_va_arg( const CodeLocation &, ExpressionNode * function, DeclarationNode * type );
    8586
    8687ast::Expr * build_enum_pos_expr( const CodeLocation &, ast::Expr * expr_node );
  • src/Parser/InitializerNode.cpp

    r960665c rad47ec4  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:20:24 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Apr  4 11:18:00 2023
    13 // Update Count     : 27
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Aug 20 22:36:22 2024
     13// Update Count     : 28
    1414//
    1515
     
    8686        } // if
    8787
    88         InitializerNode *moreInit;
     88        InitializerNode * moreInit;
    8989        if ( ( moreInit = next ) ) {
    9090                moreInit->printOneLine( os );
  • src/Parser/TypeData.cpp

    r960665c rad47ec4  
    15401540
    15411541
     1542// The argument flag (is/is not var-args) of a computed property.
     1543static ast::ArgumentFlag argumentFlag( const TypeData * td ) {
     1544        assert( td->kind == TypeData::Function );
     1545        bool isVaArgs = !td->function.params || td->function.params->hasEllipsis;
     1546        return (isVaArgs) ? ast::VariableArgs : ast::FixedArgs;
     1547} // argumentFlag
     1548
     1549
    15421550ast::FunctionDecl * buildFunctionDecl(
    15431551                const TypeData * td,
     
    15491557                std::vector<ast::ptr<ast::Attribute>> && attributes ) {
    15501558        assert( td->kind == TypeData::Function );
    1551         // For some reason FunctionDecl takes a bool instead of an ArgumentFlag.
    1552         bool isVarArgs = !td->function.params || td->function.params->hasEllipsis;
    15531559        ast::CV::Qualifiers cvq = buildQualifiers( td );
    15541560        std::vector<ast::ptr<ast::TypeDecl>> forall;
     
    16041610                std::move( attributes ),
    16051611                funcSpec,
    1606                 (isVarArgs) ? ast::VariableArgs : ast::FixedArgs
     1612                argumentFlag( td )
    16071613        );
    16081614        buildList( td->function.withExprs, decl->withExprs );
     
    16561662        assert( td->kind == TypeData::Function );
    16571663        ast::FunctionType * ft = new ast::FunctionType(
    1658                 ( !td->function.params || td->function.params->hasEllipsis )
    1659                         ? ast::VariableArgs : ast::FixedArgs,
     1664                argumentFlag( td ),
    16601665                buildQualifiers( td )
    16611666        );
  • src/Parser/parser.yy

    r960665c rad47ec4  
    792792                { $$ = new ExpressionNode( build_func( yylloc, $1, $3 ) ); }
    793793        | VA_ARG '(' primary_expression ',' declaration_specifier_nobody abstract_parameter_declarator_opt ')'
    794                 // { SemanticError( yylloc, "va_arg is currently unimplemented." ); $$ = nullptr; }
    795                 { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, new string( "__builtin_va_arg" ) ) ),
    796                                                                                            $3->set_last( (ExpressionNode *)($6 ? $6->addType( $5 ) : $5) ) ) ); }
     794                { $$ = new ExpressionNode( build_va_arg( yylloc, $3, ( $6 ? $6->addType( $5 ) : $5 ) ) ); }
    797795        | postfix_expression '`' identifier                                     // CFA, postfix call
    798796                { $$ = new ExpressionNode( build_func( yylloc, new ExpressionNode( build_varref( yylloc, build_postfix_name( $3 ) ) ), $1 ) ); }
Note: See TracChangeset for help on using the changeset viewer.