Ignore:
Timestamp:
Aug 12, 2015, 2:27:31 PM (10 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
f32c7f4
Parents:
e45215c (diff), e869d663 (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' into designate

Conflicts:

src/CodeGen/CodeGenerator.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    re45215c rd60ccbf  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  3 13:53:45 2015
    13 // Update Count     : 1220
     12// Last Modified On : Tue Aug 11 16:01:49 2015
     13// Update Count     : 1350
    1414//
    1515
     
    5454#include "lex.h"
    5555#include "ParseNode.h"
     56#include "TypeData.h"
    5657#include "LinkageSpec.h"
    5758
     
    114115        StatementNode *sn;
    115116        ConstantNode *constant;
     117        LabelNode *label;
    116118        InitializerNode *in;
     119        bool flag;
    117120}
    118121
     
    133136%type<en> argument_expression_list              argument_expression                     for_control_expression          assignment_opt
    134137%type<en> subrange
     138%type<en> asm_operands_opt asm_operands_list asm_operand
     139%type<label> label_list
     140%type<constant> asm_clobbers_list_opt
     141%type<flag> asm_volatile_opt
    135142
    136143// statements
     
    228235%type<decl> variable_abstract_ptr variable_array variable_declarator variable_function variable_ptr
    229236
     237%type<decl> attribute_list_opt attribute_list attribute
     238
    230239// initializers
    231240%type<in>  initializer initializer_list initializer_opt
     
    329338        | zero_one
    330339                { $$ = new VarRefNode( $1 ); }
    331         | constant
    332                 { $$ = $1; }
    333         | string_literal_list
    334                 { $$ = $1; }
    335340        | '(' comma_expression ')'
    336341                { $$ = $2; }
     
    375380        | assignment_expression
    376381        | no_attr_identifier ':' assignment_expression
    377                 { $$ = $3->set_asArgName( $1 ); }
     382                { $$ = $3->set_argName( $1 ); }
    378383                // Only a list of no_attr_identifier_or_type_name is allowed in this context. However, there is insufficient
    379384                // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used
    380385                // with an appropriate semantic check.
    381386        | '[' push assignment_expression pop ']' ':' assignment_expression
    382                 { $$ = $7->set_asArgName( $3 ); }
     387                { $$ = $7->set_argName( $3 ); }
    383388        | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression
    384                 { $$ = $9->set_asArgName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
     389                { $$ = $9->set_argName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
    385390        ;
    386391
     
    405410unary_expression:
    406411        postfix_expression
     412        // first location where constant/string can have operator applied: sizeof 3/sizeof "abc"
     413        // still requires semantics checks, e.g., ++3, 3--, *3, &&3
     414        | constant
     415                { $$ = $1; }
     416        | string_literal_list
     417                { $$ = $1; }
    407418        | ICR unary_expression
    408419                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Incr ), $2 ); }
     
    620631labeled_statement:
    621632        no_attr_identifier ':' attribute_list_opt statement
    622                 { $$ = $4->add_label( $1 );}
     633                {
     634                        $$ = $4->add_label( $1 );
     635                }
    623636        ;
    624637
     
    630643                // requires its own scope
    631644          push push
    632           label_declaration_opt                                                         // GCC, local labels
     645          local_label_declaration_opt                                           // GCC, local labels
    633646          block_item_list pop '}'                                                       // C99, intermix declarations and statements
    634647                { $$ = new CompoundStmtNode( $5 ); }
     
    749762
    750763fall_through:                                                                                   // CFA
    751         FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
    752         | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
     764        FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru ); }
     765        | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru ); }
    753766        ;
    754767
     
    778791        | CONTINUE ';'
    779792                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    780                 { $$ = new StatementNode( StatementNode::Continue, 0, 0 ); }
     793                { $$ = new StatementNode( StatementNode::Continue ); }
    781794        | CONTINUE no_attr_identifier ';'                                       // CFA, multi-level continue
    782795                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
     
    785798        | BREAK ';'
    786799                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    787                 { $$ = new StatementNode( StatementNode::Break, 0, 0 ); }
     800                { $$ = new StatementNode( StatementNode::Break ); }
    788801        | BREAK no_attr_identifier ';'                                          // CFA, multi-level exit
    789802                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
     
    795808                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
    796809        | THROW ';'
    797                 { $$ = new StatementNode( StatementNode::Throw, 0, 0 ); }
     810                { $$ = new StatementNode( StatementNode::Throw ); }
    798811        ;
    799812
     
    858871
    859872asm_statement:
    860         ASM type_qualifier_list_opt '(' constant_expression ')' ';'
    861                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    862         | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ')' ';' // remaining GCC
    863                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    864         | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    865                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    866         | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list ')' ';'
    867                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
     873        ASM asm_volatile_opt '(' string_literal_list ')' ';'
     874                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, 0 ); }
     875        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ')' ';' // remaining GCC
     876                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6 ); }
     877        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ')' ';'
     878                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8 ); }
     879        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';'
     880                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8, $10 ); }
     881        | ASM asm_volatile_opt GOTO '(' string_literal_list ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
     882        { $$ = new AsmStmtNode( StatementNode::Asm, $2, $5, 0, $8, $10, $12 ); }
     883        ;
     884
     885asm_volatile_opt:                                                                               // GCC
     886        // empty
     887                { $$ = false; }
     888        | VOLATILE
     889                { $$ = true; }
    868890        ;
    869891
    870892asm_operands_opt:                                                                               // GCC
    871893        // empty
     894                { $$ = 0; }                                                                             // use default argument
    872895        | asm_operands_list
    873896        ;
     
    876899        asm_operand
    877900        | asm_operands_list ',' asm_operand
     901                { $$ = (ExpressionNode *)$1->set_link( $3 ); }
    878902        ;
    879903
    880904asm_operand:                                                                                    // GCC
    881         STRINGliteral '(' constant_expression ')'       {}
    882         ;
    883 
    884 asm_clobbers_list:                                                                              // GCC
    885         STRINGliteral                                                           {}
    886         | asm_clobbers_list ',' STRINGliteral
     905        string_literal_list '(' constant_expression ')'
     906                { $$ = new AsmExprNode( 0, $1, $3 ); }
     907        | '[' constant_expression ']' string_literal_list '(' constant_expression ')'
     908                { $$ = new AsmExprNode( $2, $4, $6 ); }
     909        ;
     910
     911asm_clobbers_list_opt:                                                                          // GCC
     912        // empty
     913                { $$ = 0; }                                                                             // use default argument
     914        | string_literal_list
     915                { $$ = $1; }
     916        | asm_clobbers_list_opt ',' string_literal_list
     917                { $$ = (ConstantNode *)$1->set_link( $3 ); }
     918        ;
     919
     920label_list:
     921        no_attr_identifier
     922                { $$ = new LabelNode(); $$->append_label( $1 ); }
     923        | label_list ',' no_attr_identifier
     924                { $$ = $1; $1->append_label( $3 ); }
    887925        ;
    888926
     
    913951        ;
    914952
    915 label_declaration_opt:                                                                  // GCC, local label
     953local_label_declaration_opt:                                                    // GCC, local label
    916954        // empty
    917         | label_declaration_list
    918         ;
    919 
    920 label_declaration_list:                                                                 // GCC, local label
    921         LABEL label_list ';'
    922         | label_declaration_list LABEL label_list ';'
    923         ;
    924 
    925 label_list:                                                                                             // GCC, local label
    926         no_attr_identifier_or_type_name                 {}
    927         | label_list ',' no_attr_identifier_or_type_name {}
     955        | local_label_declaration_list
     956        ;
     957
     958local_label_declaration_list:                                                   // GCC, local label
     959        LABEL local_label_list ';'
     960        | local_label_declaration_list LABEL local_label_list ';'
     961        ;
     962
     963local_label_list:                                                                               // GCC, local label
     964        no_attr_identifier_or_type_name                         {}
     965        | local_label_list ',' no_attr_identifier_or_type_name {}
    928966        ;
    929967
     
    11821220        type_qualifier_name
    11831221        | attribute
    1184                 { $$ = DeclarationNode::newQualifier( DeclarationNode::Attribute ); }
     1222        //{ $$ = DeclarationNode::newQualifier( DeclarationNode::Attribute ); }
    11851223        ;
    11861224
     
    16551693
    16561694designator:
    1657         '.' no_attr_identifier_or_type_name                                     // C99, field name
    1658                 { $$ = new VarRefNode( $2 ); }
     1695        // only ".0" and ".1" allowed => semantic check
     1696        FLOATINGconstant
     1697                { $$ = new DesignatorNode( new VarRefNode( $1 ) ); }
     1698        | '.' no_attr_identifier_or_type_name                           // C99, field name
     1699                { $$ = new DesignatorNode( new VarRefNode( $2 ) ); }
    16591700        | '[' push assignment_expression pop ']'                        // C99, single array element
    16601701                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
    1661                 { $$ = $3; }
     1702                { $$ = new DesignatorNode( $3, true ); }
    16621703        | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    1663                 { $$ = $3; }
     1704                { $$ = new DesignatorNode( $3, true ); }
    16641705        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    1665                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ); }
     1706                { $$ = new DesignatorNode( new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ), true ); }
    16661707        | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    1667                 { $$ = $4; }
     1708                { $$ = new DesignatorNode( $4 ); }
    16681709        ;
    16691710
     
    19972038attribute_list_opt:                                                                             // GCC
    19982039        // empty
     2040                { $$ = 0; }
    19992041        | attribute_list
    20002042        ;
     
    20032045        attribute
    20042046        | attribute_list attribute
     2047                { $$ = $2->addQualifiers( $1 ); }
    20052048        ;
    20062049
    20072050attribute:                                                                                              // GCC
    20082051        ATTRIBUTE '(' '(' attribute_parameter_list ')' ')'
     2052        //              { $$ = DeclarationNode::newQualifier( DeclarationNode::Attribute ); }
     2053                { $$ = 0; }
    20092054        ;
    20102055
     
    20592104variable_declarator:
    20602105        paren_identifier attribute_list_opt
     2106                { $$ = $1->addQualifiers( $2 ); }
    20612107        | variable_ptr
    20622108        | variable_array attribute_list_opt
     2109                { $$ = $1->addQualifiers( $2 ); }
    20632110        | variable_function attribute_list_opt
     2111                { $$ = $1->addQualifiers( $2 ); }
    20642112        ;
    20652113
     
    21082156function_declarator:
    21092157        function_no_ptr attribute_list_opt
     2158                { $$ = $1->addQualifiers( $2 ); }
    21102159        | function_ptr
    21112160        | function_array attribute_list_opt
     2161                { $$ = $1->addQualifiers( $2 ); }
    21122162        ;
    21132163
     
    21882238type_redeclarator:
    21892239        paren_type attribute_list_opt
     2240                { $$ = $1->addQualifiers( $2 ); }
    21902241        | type_ptr
    21912242        | type_array attribute_list_opt
     2243                { $$ = $1->addQualifiers( $2 ); }
    21922244        | type_function attribute_list_opt
     2245                { $$ = $1->addQualifiers( $2 ); }
    21932246        ;
    21942247
     
    22352288identifier_parameter_declarator:
    22362289        paren_identifier attribute_list_opt
     2290                { $$ = $1->addQualifiers( $2 ); }
    22372291        | identifier_parameter_ptr
    22382292        | identifier_parameter_array attribute_list_opt
     2293                { $$ = $1->addQualifiers( $2 ); }
    22392294        | identifier_parameter_function attribute_list_opt
     2295                { $$ = $1->addQualifiers( $2 ); }
    22402296        ;
    22412297
     
    22972353type_parameter_redeclarator:
    22982354        typedef attribute_list_opt
     2355                { $$ = $1->addQualifiers( $2 ); }
    22992356        | type_parameter_ptr
    23002357        | type_parameter_array attribute_list_opt
     2358                { $$ = $1->addQualifiers( $2 ); }
    23012359        | type_parameter_function attribute_list_opt
     2360                { $$ = $1->addQualifiers( $2 ); }
    23022361        ;
    23032362
     
    23502409        abstract_ptr
    23512410        | abstract_array attribute_list_opt
     2411                { $$ = $1->addQualifiers( $2 ); }
    23522412        | abstract_function attribute_list_opt
     2413                { $$ = $1->addQualifiers( $2 ); }
    23532414        ;
    23542415
     
    24172478        abstract_parameter_ptr
    24182479        | abstract_parameter_array attribute_list_opt
     2480                { $$ = $1->addQualifiers( $2 ); }
    24192481        | abstract_parameter_function attribute_list_opt
     2482                { $$ = $1->addQualifiers( $2 ); }
    24202483        ;
    24212484
     
    24932556        variable_abstract_ptr
    24942557        | variable_abstract_array attribute_list_opt
     2558                { $$ = $1->addQualifiers( $2 ); }
    24952559        | variable_abstract_function attribute_list_opt
     2560                { $$ = $1->addQualifiers( $2 ); }
    24962561        ;
    24972562
Note: See TracChangeset for help on using the changeset viewer.