Changes in / [3b5dcfa:b738974]


Ignore:
Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.h

    r3b5dcfa rb738974  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 19 10:09:17 2018
    13 // Update Count     : 31
     12// Last Modified On : Wed May  4 14:08:26 2022
     13// Update Count     : 35
    1414//
    1515
     
    5959        {"aggregate-forward-decl" , Severity::Warn    , "forward declaration of nested aggregate: %s"                },
    6060        {"superfluous-decl"       , Severity::Warn    , "declaration does not allocate storage: %s"                  },
     61        {"superfluous-else"       , Severity::Warn    , "else clause never executed for empty loop conditional"      },
    6162        {"gcc-attributes"         , Severity::Warn    , "invalid attribute: %s"                                      },
    6263        {"c++-like-copy"          , Severity::Warn    , "Constructor from reference is not a valid copy constructor" },
     
    6970        AggrForwardDecl,
    7071        SuperfluousDecl,
     72        SuperfluousElse,
    7173        GccAttributes,
    7274        CppCopy,
     
    7981);
    8082
    81 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id].message, __VA_ARGS__)
     83#define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id].message, ##__VA_ARGS__)
    8284
    8385void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4)));
  • src/Parser/parser.yy

    r3b5dcfa rb738974  
    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 14:25:20 2022
     13// Update Count     : 5277
    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                { SemanticWarning( yylloc, Warning::SuperfluousElse ); }
    12251227        | WHILE '(' conditional_declaration ')' statement       %prec THEN
    12261228                { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); }
     
    12291231        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    12301232                { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); }
     1233        | DO statement WHILE '(' ')' ELSE statement                     // CFA
     1234                { SemanticWarning( yylloc, Warning::SuperfluousElse ); }
    12311235        | DO statement WHILE '(' comma_expression ')' ';'       %prec THEN
    12321236                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
     
    23182322                        { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    23192323
    2320                         $$ = DeclarationNode::newEnum( nullptr, $7, true, $3 ) ->addQualifiers( $5 );
     2324                        $$ = DeclarationNode::newEnum( nullptr, $7, true, $3 )->addQualifiers( $5 );
    23212325                }
    23222326        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
     
    23272331          '{' enumerator_list comma_opt '}'
    23282332                {
    2329                         $$ = DeclarationNode::newEnum( $6, $10, true, $3 ) -> addQualifiers( $5 ) -> addQualifiers( $7 );
     2333                        $$ = DeclarationNode::newEnum( $6, $10, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );
    23302334                }
    23312335        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}'
     
    23332337                        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." ); }
    23342338                        typedefTable.makeTypedef( *$6->name );
    2335                         $$ = DeclarationNode::newEnum( $6->name, $9, true, $3 ) -> addQualifiers( $5 ) -> addQualifiers( $7 );
     2339                        $$ = DeclarationNode::newEnum( $6->name, $9, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );
    23362340                }
    23372341        | enum_type_nobody
Note: See TracChangeset for help on using the changeset viewer.