Changeset a16764a6 for src/Parser


Ignore:
Timestamp:
Feb 28, 2018, 4:48:22 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
446ffa3
Parents:
6a8df56
Message:

Changed warning system to prepare for toggling warnings

Location:
src/Parser
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r6a8df56 ra16764a6  
    576576                                        dst->basictype = src->basictype;
    577577                                } else if ( src->basictype != DeclarationNode::NoBasicType )
    578                                         throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::basicTypeNames[ src->basictype ] + " in type: " );
     578                                        SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::basicTypeNames[ src->basictype ] + " in type: " );
    579579
    580580                                if ( dst->complextype == DeclarationNode::NoComplexType ) {
    581581                                        dst->complextype = src->complextype;
    582582                                } else if ( src->complextype != DeclarationNode::NoComplexType )
    583                                         throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::complexTypeNames[ src->complextype ] + " in type: " );
     583                                        SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::complexTypeNames[ src->complextype ] + " in type: " );
    584584
    585585                                if ( dst->signedness == DeclarationNode::NoSignedness ) {
    586586                                        dst->signedness = src->signedness;
    587587                                } else if ( src->signedness != DeclarationNode::NoSignedness )
    588                                         throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::signednessNames[ src->signedness ] + " in type: " );
     588                                        SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::signednessNames[ src->signedness ] + " in type: " );
    589589
    590590                                if ( dst->length == DeclarationNode::NoLength ) {
     
    593593                                        dst->length = DeclarationNode::LongLong;
    594594                                } else if ( src->length != DeclarationNode::NoLength )
    595                                         throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::lengthNames[ src->length ] + " in type: " );
     595                                        SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::lengthNames[ src->length ] + " in type: " );
    596596                        } // if
    597597                        break;
     
    940940
    941941void buildList( const DeclarationNode * firstNode, std::list< Declaration * > &outputList ) {
    942         SemanticError errors;
     942        SemanticErrorException errors;
    943943        std::back_insert_iterator< std::list< Declaration * > > out( outputList );
    944944
     
    960960                                * out++ = decl;
    961961                        } // if
    962                 } catch( SemanticError &e ) {
     962                } catch( SemanticErrorException &e ) {
    963963                        errors.append( e );
    964964                } // try
     
    971971
    972972void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > &outputList ) {
    973         SemanticError errors;
     973        SemanticErrorException errors;
    974974        std::back_insert_iterator< std::list< DeclarationWithType * > > out( outputList );
    975975
     
    994994                                } // if
    995995                        } // if
    996                 } catch( SemanticError &e ) {
     996                } catch( SemanticErrorException &e ) {
    997997                        errors.append( e );
    998998                } // try
     
    10051005
    10061006void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > &outputList ) {
    1007         SemanticError errors;
     1007        SemanticErrorException errors;
    10081008        std::back_insert_iterator< std::list< Type * > > out( outputList );
    10091009        const DeclarationNode * cur = firstNode;
     
    10121012                try {
    10131013                        * out++ = cur->buildType();
    1014                 } catch( SemanticError &e ) {
     1014                } catch( SemanticErrorException &e ) {
    10151015                        errors.append( e );
    10161016                } // try
     
    10241024
    10251025Declaration * DeclarationNode::build() const {
    1026         if ( ! error.empty() ) throw SemanticError( this, error + " in declaration of " );
     1026        if ( ! error.empty() ) SemanticError( this, error + " in declaration of " );
    10271027
    10281028        if ( asmStmt ) {
     
    10471047                //    inline _Noreturn int i;                   // disallowed
    10481048                if ( type->kind != TypeData::Function && funcSpecs.any() ) {
    1049                         throw SemanticError( this, "invalid function specifier for " );
     1049                        SemanticError( this, "invalid function specifier for " );
    10501050                } // if
    10511051                return buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild< Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, maybeBuild< Initializer >(initializer), attributes )->set_extension( extension );
     
    10571057        //    inlne _Noreturn enum   E { ... };         // disallowed
    10581058        if ( funcSpecs.any() ) {
    1059                 throw SemanticError( this, "invalid function specifier for " );
     1059                SemanticError( this, "invalid function specifier for " );
    10601060        } // if
    10611061        assertf( name, "ObjectDecl must a have name\n" );
  • src/Parser/ExpressionNode.cc

    r6a8df56 ra16764a6  
    356356
    357357Expression * build_field_name_FLOATING_FRACTIONconstant( const string & str ) {
    358         if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) throw SemanticError( yylloc, "invalid tuple index " + str );
     358        if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) SemanticError( yylloc, "invalid tuple index " + str );
    359359        Expression * ret = build_constantInteger( *new string( str.substr(1) ) );
    360360        delete &str;
     
    363363
    364364Expression * build_field_name_FLOATING_DECIMALconstant( const string & str ) {
    365         if ( str[str.size()-1] != '.' ) throw SemanticError( yylloc, "invalid tuple index " + str );
     365        if ( str[str.size()-1] != '.' ) SemanticError( yylloc, "invalid tuple index " + str );
    366366        Expression * ret = build_constantInteger( *new string( str.substr( 0, str.size()-1 ) ) );
    367367        delete &str;
  • src/Parser/LinkageSpec.cc

    r6a8df56 ra16764a6  
    3434                return BuiltinC;
    3535        } else {
    36                 throw SemanticError( location, "Invalid linkage specifier " + *spec );
     36                SemanticError( location, "Invalid linkage specifier " + *spec );
    3737        } // if
    3838}
     
    4848                return old_spec;
    4949        } else {
    50                 throw SemanticError( location, "Invalid linkage specifier " + *cmd );
     50                SemanticError( location, "Invalid linkage specifier " + *cmd );
    5151        } // if
    5252}
  • src/Parser/ParseNode.h

    r6a8df56 ra16764a6  
    419419template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args >
    420420void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > &outputList ) {
    421         SemanticError errors;
     421        SemanticErrorException errors;
    422422        std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList );
    423423        const NodeType * cur = firstNode;
     
    432432                                assertf(false, "buildList unknown type");
    433433                        } // if
    434                 } catch( SemanticError &e ) {
     434                } catch( SemanticErrorException &e ) {
    435435                        errors.append( e );
    436436                } // try
  • src/Parser/TypeData.cc

    r6a8df56 ra16764a6  
    519519
    520520static string genTSError( string msg, DeclarationNode::BasicType basictype ) {
    521         throw SemanticError( yylloc, string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." );
     521        SemanticError( yylloc, string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." );
    522522} // genTSError
    523523
     
    919919                                // type set => parameter name already transformed by a declaration names so there is a duplicate
    920920                                // declaration name attempting a second transformation
    921                                 if ( param->type ) throw SemanticError( param->location, string( "duplicate declaration name " ) + *param->name );
     921                                if ( param->type ) SemanticError( param->location, string( "duplicate declaration name " ) + *param->name );
    922922                                // declaration type reset => declaration already transformed by a parameter name so there is a duplicate
    923923                                // parameter name attempting a second transformation
    924                                 if ( ! decl->type ) throw SemanticError( param->location, string( "duplicate parameter name " ) + *param->name );
     924                                if ( ! decl->type ) SemanticError( param->location, string( "duplicate parameter name " ) + *param->name );
    925925                                param->type = decl->type;                               // set copy declaration type to parameter type
    926926                                decl->type = nullptr;                                   // reset declaration type
     
    929929                } // for
    930930                // declaration type still set => type not moved to a matching parameter so there is a missing parameter name
    931                 if ( decl->type ) throw SemanticError( decl->location, string( "missing name in parameter list " ) + *decl->name );
     931                if ( decl->type ) SemanticError( decl->location, string( "missing name in parameter list " ) + *decl->name );
    932932        } // for
    933933
  • src/Parser/lex.ll

    r6a8df56 ra16764a6  
    453453void yyerror( const char * errmsg ) {
    454454        cout << (yyfilename ? yyfilename : "*unknown file*") << ':' << yylineno << ':' << column - yyleng + 1
    455                  << ": " << SemanticError::error_str() << errmsg << " at token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl;
     455                 << ": " << ErrorHelpers::error_str() << errmsg << " at token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl;
    456456}
    457457
  • src/Parser/parser.yy

    r6a8df56 ra16764a6  
    482482                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
    483483        | type_name '.' no_attr_identifier                                      // CFA, nested type
    484                 { throw SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
     484                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
    485485        | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
    486                 { throw SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
     486                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
    487487        | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
    488                 { throw SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME
     488                { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME
    489489        ;
    490490
     
    780780                { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
    781781        | unary_expression '=' '{' initializer_list comma_opt '}'
    782                 { throw SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME
     782                { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME
    783783        ;
    784784
     
    850850        | exception_statement
    851851        | enable_disable_statement
    852                 { throw SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
     852                { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
    853853        | asm_statement
    854854        ;
     
    10671067                { $$ = new StatementNode( build_return( $2 ) ); }
    10681068        | RETURN '{' initializer_list comma_opt '}'
    1069                 { throw SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1069                { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME
    10701070        | THROW assignment_expression_opt ';'                           // handles rethrow
    10711071                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    10861086mutex_statement:
    10871087        MUTEX '(' argument_expression_list ')' statement
    1088                 { throw SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1088                { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
    10891089        ;
    10901090
     
    13161316static_assert:
    13171317        STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11
    1318                 { throw SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; }   // FIX ME
     1318                { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME
    13191319
    13201320// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
Note: See TracChangeset for help on using the changeset viewer.