Ignore:
Timestamp:
May 10, 2022, 12:25:05 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
8faa6612
Parents:
3b80db8 (diff), 7edd5c1 (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r3b80db8 r00675a1  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 14 16:35:29 2022
    13 // Update Count     : 5276
     12// Last Modified On : Wed May  4 17:22:48 2022
     13// Update Count     : 5279
    1414//
    1515
     
    111111
    112112void distInl( DeclarationNode * declaration ) {
    113         // distribute EXTENSION across all declarations
     113        // distribute INLINE across all declarations
    114114        for ( DeclarationNode *iter = declaration; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
    115115                iter->set_inLine( true );
     
    12211221
    12221222iteration_statement:
    1223         WHILE '(' ')' statement                                                         // CFA => while ( 1 )
     1223        WHILE '(' ')' statement                                                         %prec THEN // CFA => while ( 1 )
    12241224                { $$ = new StatementNode( build_while( new CondCtl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); }
     1225        | WHILE '(' ')' statement ELSE statement                        // CFA
     1226                {
     1227                        $$ = new StatementNode( build_while( new CondCtl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) );
     1228                        SemanticWarning( yylloc, Warning::SuperfluousElse );
     1229                }
    12251230        | WHILE '(' conditional_declaration ')' statement       %prec THEN
    12261231                { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); }
     
    12291234        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    12301235                { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); }
    1231         | DO statement WHILE '(' comma_expression ')' ';'       %prec THEN
     1236        | DO statement WHILE '(' ')' ELSE statement                     // CFA
     1237                {
     1238                        $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) );
     1239                        SemanticWarning( yylloc, Warning::SuperfluousElse );
     1240                }
     1241        | DO statement WHILE '(' comma_expression ')' ';'
    12321242                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
    12331243        | DO statement WHILE '(' comma_expression ')' ELSE statement // CFA
    12341244                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ), $8 ) ); }
    1235         | FOR '(' ')' statement                                                         // CFA => for ( ;; )
     1245        | FOR '(' ')' statement                                                         %prec THEN // CFA => for ( ;; )
    12361246                { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); }
     1247        | FOR '(' ')' statement ELSE statement                          // CFA
     1248                {
     1249                        $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) );
     1250                        SemanticWarning( yylloc, Warning::SuperfluousElse );
     1251                }
    12371252        | FOR '(' for_control_expression_list ')' statement     %prec THEN
    12381253                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }
     
    23182333                        { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    23192334
    2320                         $$ = DeclarationNode::newEnum( nullptr, $7, true, $3 ) ->addQualifiers( $5 );
     2335                        $$ = DeclarationNode::newEnum( nullptr, $7, true, $3 )->addQualifiers( $5 );
    23212336                }
    23222337        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
     
    23272342          '{' enumerator_list comma_opt '}'
    23282343                {
    2329                         $$ = DeclarationNode::newEnum( $6, $10, true, $3 ) -> addQualifiers( $5 ) -> addQualifiers( $7 );
     2344                        $$ = DeclarationNode::newEnum( $6, $10, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );
    23302345                }
    23312346        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}'
     
    23332348                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    23342349                        typedefTable.makeTypedef( *$6->name );
    2335                         $$ = DeclarationNode::newEnum( $6->name, $9, true, $3 ) -> addQualifiers( $5 ) -> addQualifiers( $7 );
     2350                        $$ = DeclarationNode::newEnum( $6->name, $9, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );
    23362351                }
    23372352        | enum_type_nobody
Note: See TracChangeset for help on using the changeset viewer.