Changeset 2a8427c6


Ignore:
Timestamp:
Feb 22, 2018, 4:52:25 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, resolv-new, with_gc
Children:
8f13c98
Parents:
4ada74e
Message:

adjust meaning of var-args for C empty parameter list

Location:
src/Parser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r4ada74e r2a8427c6  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Nov 20 09:21:52 2017
    13 // Update Count     : 1031
     12// Last Modified On : Thu Feb 22 15:37:17 2018
     13// Update Count     : 1033
    1414//
    1515
     
    120120} // DeclarationNode::clone
    121121
    122 bool DeclarationNode::get_hasEllipsis() const {
    123         return hasEllipsis;
    124 }
    125 
    126122void DeclarationNode::print( std::ostream &os, int indent ) const {
    127123        os << string( indent, ' ' );
     
    167163}
    168164
    169 DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle ) {
     165DeclarationNode * DeclarationNode::newFunction( string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ) {
    170166        DeclarationNode * newnode = new DeclarationNode;
    171167        newnode->name = name;
    172168        newnode->type = new TypeData( TypeData::Function );
    173169        newnode->type->function.params = param;
    174         newnode->type->function.newStyle = newStyle;
    175170        newnode->type->function.body = body;
    176171
  • src/Parser/ParseNode.h

    r4ada74e r2a8427c6  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Nov 27 17:33:35 2017
    13 // Update Count     : 824
     12// Last Modified On : Thu Feb 22 15:31:48 2018
     13// Update Count     : 826
    1414//
    1515
     
    226226        static DeclarationNode * newForall( DeclarationNode * );
    227227        static DeclarationNode * newFromTypedef( std::string * );
    228         static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body, bool newStyle = false );
     228        static DeclarationNode * newFunction( std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );
    229229        static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
    230230        static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants, bool body );
     
    288288        Type * buildType() const;
    289289
    290         bool get_hasEllipsis() const;
    291290        LinkageSpec::Spec get_linkage() const { return linkage; }
    292291        DeclarationNode * extractAggregate() const;
  • src/Parser/TypeData.cc

    r4ada74e r2a8427c6  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 25 18:33:41 2017
    13 // Update Count     : 587
     12// Last Modified On : Thu Feb 22 15:49:00 2018
     13// Update Count     : 597
    1414//
    1515
     
    5454                function.oldDeclList = nullptr;
    5555                function.body = nullptr;
    56                 function.newStyle = false;
    5756                function.withExprs = nullptr;
    5857                break;
     
    195194                newtype->function.oldDeclList = maybeClone( function.oldDeclList );
    196195                newtype->function.body = maybeClone( function.body );
    197                 newtype->function.newStyle = function.newStyle;
    198196                newtype->function.withExprs = maybeClone( function.withExprs );
    199197                break;
     
    881879FunctionType * buildFunction( const TypeData * td ) {
    882880        assert( td->kind == TypeData::Function );
    883         bool hasEllipsis = td->function.params ? td->function.params->get_hasEllipsis() : true;
    884         if ( ! td->function.params ) hasEllipsis = ! td->function.newStyle;
    885         FunctionType * ft = new FunctionType( buildQualifiers( td ), hasEllipsis );
     881        FunctionType * ft = new FunctionType( buildQualifiers( td ), ! td->function.params || td->function.params->hasEllipsis );
    886882        buildList( td->function.params, ft->get_parameters() );
    887883        buildForall( td->forall, ft->get_forall() );
  • src/Parser/TypeData.h

    r4ada74e r2a8427c6  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Sep  1 23:33:45 2017
    13 // Update Count     : 190
     12// Last Modified On : Thu Feb 22 15:21:23 2018
     13// Update Count     : 191
    1414//
    1515
     
    6464                mutable DeclarationNode * oldDeclList;
    6565                StatementNode * body;
    66                 bool newStyle;
    6766                ExpressionNode * withExprs;             // expressions from function's with_clause
    6867        };
  • src/Parser/parser.yy

    r4ada74e r2a8427c6  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 15 17:12:31 2018
    13 // Update Count     : 3006
     12// Last Modified On : Thu Feb 22 15:31:19 2018
     13// Update Count     : 3027
    1414//
    1515
     
    314314%type<decl> cfa_identifier_parameter_declarator_tuple cfa_identifier_parameter_ptr
    315315
    316 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list cfa_parameter_type_list_opt
     316%type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list_opt
    317317
    318318%type<decl> cfa_typedef_declaration cfa_variable_declaration cfa_variable_specifier
     
    322322%type<decl> KR_declaration_list KR_declaration_list_opt
    323323
    324 %type<decl> parameter_declaration parameter_list parameter_type_list
    325 %type<decl> parameter_type_list_opt
     324%type<decl> parameter_declaration parameter_list parameter_type_list_opt
    326325
    327326%type<decl> paren_identifier paren_type
     
    779778        | unary_expression assignment_operator assignment_expression
    780779                { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
    781         | unary_expression '=' '{' initializer_list comma_opt '}' // FIX ME
    782                 { $$ = nullptr; }
     780        | unary_expression '=' '{' initializer_list comma_opt '}'
     781                { throw SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME
    783782        ;
    784783
     
    849848        | waitfor_statement
    850849        | exception_statement
     850        | enable_disable_statement
     851                { throw SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
    851852        | asm_statement
    852853        ;
     
    10641065        | RETURN comma_expression_opt ';'
    10651066                { $$ = new StatementNode( build_return( $2 ) ); }
    1066         | RETURN '{' initializer_list comma_opt '}'                     // FIX ME
    1067                 { $$ = nullptr; }
     1067        | RETURN '{' initializer_list comma_opt '}'
     1068                { throw SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME
    10681069        | THROW assignment_expression_opt ';'                           // handles rethrow
    10691070                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    11931194        ;
    11941195
     1196enable_disable_statement:
     1197        enable_disable_key identifier_list compound_statement
     1198        ;
     1199
     1200enable_disable_key:
     1201        ENABLE
     1202        | DISABLE
     1203        ;
     1204
    11951205asm_statement:
    11961206        ASM asm_volatile_opt '(' string_literal ')' ';'
     
    13921402                        DeclarationNode * ret = new DeclarationNode;
    13931403                        ret->type = maybeClone( $1->type->base );
    1394                         $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr, true ) );
     1404                        $$ = $1->appendList( DeclarationNode::newFunction( $5, ret, $8, nullptr ) );
    13951405                }
    13961406        ;
     
    14221432                // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator).
    14231433                {
    1424                         $$ = DeclarationNode::newFunction( $2, $1, $5, 0, true );
     1434                        $$ = DeclarationNode::newFunction( $2, $1, $5, 0 );
    14251435                }
    14261436        | cfa_function_return identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')'
    14271437                {
    1428                         $$ = DeclarationNode::newFunction( $2, $1, $5, 0, true );
     1438                        $$ = DeclarationNode::newFunction( $2, $1, $5, 0 );
    14291439                }
    14301440        ;
     
    19902000        ;
    19912001
    1992 // Minimum of one parameter after which ellipsis is allowed only at the end.
    1993 
    1994 cfa_parameter_type_list_opt:                                                    // CFA
     2002cfa_parameter_type_list_opt:                                                    // CFA, abstract + real
    19952003        // empty
     2004                { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); }
     2005        | ELLIPSIS
    19962006                { $$ = nullptr; }
    1997         | cfa_parameter_type_list
    1998         ;
    1999 
    2000 cfa_parameter_type_list:                                                                // CFA, abstract + real
    2001         cfa_abstract_parameter_list
     2007        | cfa_abstract_parameter_list
    20022008        | cfa_parameter_list
    20032009        | cfa_parameter_list pop ',' push cfa_abstract_parameter_list
     
    20302036        // empty
    20312037                { $$ = nullptr; }
    2032         | parameter_type_list
    2033         ;
    2034 
    2035 parameter_type_list:
    2036         parameter_list
     2038        | ELLIPSIS
     2039                { $$ = nullptr; }
     2040        | parameter_list
    20372041        | parameter_list pop ',' push ELLIPSIS
    20382042                { $$ = $1->addVarArgs(); }
Note: See TracChangeset for help on using the changeset viewer.