Changeset d55d7a6 for src/Parser


Ignore:
Timestamp:
Feb 15, 2018, 3:58:56 PM (6 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:
75e3cb2
Parents:
d27e340
Message:

Massive change to errors to enable warnings

Location:
src/Parser
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rd27e340 rd55d7a6  
    581581                                        dst->basictype = src->basictype;
    582582                                } else if ( src->basictype != DeclarationNode::NoBasicType )
    583                                         throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::basicTypeNames[ src->basictype ] + " in type: ", src );
     583                                        throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::basicTypeNames[ src->basictype ] + " in type: " );
    584584
    585585                                if ( dst->complextype == DeclarationNode::NoComplexType ) {
    586586                                        dst->complextype = src->complextype;
    587587                                } else if ( src->complextype != DeclarationNode::NoComplexType )
    588                                         throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::complexTypeNames[ src->complextype ] + " in type: ", src );
     588                                        throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::complexTypeNames[ src->complextype ] + " in type: " );
    589589
    590590                                if ( dst->signedness == DeclarationNode::NoSignedness ) {
    591591                                        dst->signedness = src->signedness;
    592592                                } else if ( src->signedness != DeclarationNode::NoSignedness )
    593                                         throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::signednessNames[ src->signedness ] + " in type: ", src );
     593                                        throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::signednessNames[ src->signedness ] + " in type: " );
    594594
    595595                                if ( dst->length == DeclarationNode::NoLength ) {
     
    598598                                        dst->length = DeclarationNode::LongLong;
    599599                                } else if ( src->length != DeclarationNode::NoLength )
    600                                         throw SemanticError( string( "conflicting type specifier " ) + DeclarationNode::lengthNames[ src->length ] + " in type: ", src );
     600                                        throw SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::lengthNames[ src->length ] + " in type: " );
    601601                        } // if
    602602                        break;
     
    966966                        } // if
    967967                } catch( SemanticError &e ) {
    968                         e.set_location( cur->location );
    969968                        errors.append( e );
    970969                } // try
     
    10011000                        } // if
    10021001                } catch( SemanticError &e ) {
    1003                         e.set_location( cur->location );
    10041002                        errors.append( e );
    10051003                } // try
     
    10201018                        * out++ = cur->buildType();
    10211019                } catch( SemanticError &e ) {
    1022                         e.set_location( cur->location );
    10231020                        errors.append( e );
    10241021                } // try
     
    10321029
    10331030Declaration * DeclarationNode::build() const {
    1034         if ( ! error.empty() ) throw SemanticError( error + " in declaration of ", this );
     1031        if ( ! error.empty() ) throw SemanticError( this, error + " in declaration of " );
    10351032
    10361033        if ( asmStmt ) {
     
    10551052                //    inline _Noreturn int i;                   // disallowed
    10561053                if ( type->kind != TypeData::Function && funcSpecs.any() ) {
    1057                         throw SemanticError( "invalid function specifier for ", this );
     1054                        throw SemanticError( this, "invalid function specifier for " );
    10581055                } // if
    10591056                return buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild< Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, maybeBuild< Initializer >(initializer), attributes )->set_extension( extension );
     
    10651062        //    inlne _Noreturn enum   E { ... };         // disallowed
    10661063        if ( funcSpecs.any() ) {
    1067                 throw SemanticError( "invalid function specifier for ", this );
     1064                throw SemanticError( this, "invalid function specifier for " );
    10681065        } // if
    10691066        assertf( name, "ObjectDecl must a have name\n" );
  • src/Parser/ExpressionNode.cc

    rd27e340 rd55d7a6  
    356356
    357357Expression * build_field_name_FLOATING_FRACTIONconstant( const string & str ) {
    358         if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) throw SemanticError( "invalid tuple index " + str );
     358        if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) throw 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( "invalid tuple index " + str );
     365        if ( str[str.size()-1] != '.' ) throw 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

    rd27e340 rd55d7a6  
    2424namespace LinkageSpec {
    2525
    26 Spec linkageCheck( const string * spec ) {
     26Spec linkageCheck( CodeLocation location, const string * spec ) {
    2727        assert( spec );
    2828        unique_ptr<const string> guard( spec ); // allocated by lexer
     
    3434                return BuiltinC;
    3535        } else {
    36                 throw SemanticError( "Invalid linkage specifier " + *spec );
     36                throw SemanticError( location, "Invalid linkage specifier " + *spec );
    3737        } // if
    3838}
    3939
    40 Spec linkageUpdate( Spec old_spec, const string * cmd ) {
     40Spec linkageUpdate( CodeLocation location, Spec old_spec, const string * cmd ) {
    4141        assert( cmd );
    4242        unique_ptr<const string> guard( cmd ); // allocated by lexer
     
    4848                return old_spec;
    4949        } else {
    50                 throw SemanticError( "Invalid linkage specifier " + *cmd );
     50                throw SemanticError( location, "Invalid linkage specifier " + *cmd );
    5151        } // if
    5252}
  • src/Parser/LinkageSpec.h

    rd27e340 rd55d7a6  
    1717
    1818#include <string>
     19
     20#include "Common/CodeLocation.h"
    1921
    2022namespace LinkageSpec {
     
    4547
    4648
    47         Spec linkageCheck( const std::string * );
     49        Spec linkageCheck( CodeLocation location, const std::string * );
    4850        // Returns the Spec with the given name (limited to C, Cforall & BuiltinC)
    49         Spec linkageUpdate( Spec old_spec, const std::string * cmd );
     51        Spec linkageUpdate( CodeLocation location, Spec old_spec, const std::string * cmd );
    5052        /* If cmd = "C" returns a Spec that is old_spec with is_mangled = false
    5153         * If cmd = "Cforall" returns old_spec Spec with is_mangled = true
  • src/Parser/ParseNode.h

    rd27e340 rd55d7a6  
    434434                        } // if
    435435                } catch( SemanticError &e ) {
    436                         e.set_location( cur->location );
    437436                        errors.append( e );
    438437                } // try
  • src/Parser/TypeData.cc

    rd27e340 rd55d7a6  
    521521
    522522static string genTSError( string msg, DeclarationNode::BasicType basictype ) {
    523         throw SemanticError( string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." );
     523        throw SemanticError( yylloc, string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." );
    524524} // genTSError
    525525
     
    923923                                // type set => parameter name already transformed by a declaration names so there is a duplicate
    924924                                // declaration name attempting a second transformation
    925                                 if ( param->type ) throw SemanticError( string( "duplicate declaration name " ) + *param->name );
     925                                if ( param->type ) throw SemanticError( param->location, string( "duplicate declaration name " ) + *param->name );
    926926                                // declaration type reset => declaration already transformed by a parameter name so there is a duplicate
    927927                                // parameter name attempting a second transformation
    928                                 if ( ! decl->type ) throw SemanticError( string( "duplicate parameter name " ) + *param->name );
     928                                if ( ! decl->type ) throw SemanticError( param->location, string( "duplicate parameter name " ) + *param->name );
    929929                                param->type = decl->type;                               // set copy declaration type to parameter type
    930930                                decl->type = nullptr;                                   // reset declaration type
     
    933933                } // for
    934934                // declaration type still set => type not moved to a matching parameter so there is a missing parameter name
    935                 if ( decl->type ) throw SemanticError( string( "missing name in parameter list " ) + *decl->name );
     935                if ( decl->type ) throw SemanticError( decl->location, string( "missing name in parameter list " ) + *decl->name );
    936936        } // for
    937937
  • src/Parser/parser.yy

    rd27e340 rd55d7a6  
    482482                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
    483483        | type_name '.' no_attr_identifier                                      // CFA, nested type
    484                 { throw SemanticError("Qualified names are currently unimplemented."); $$ = nullptr; } // FIX ME
     484                { throw 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("Qualified names are currently unimplemented."); $$ = nullptr; } // FIX ME
     486                { throw SemanticError(yylloc, "Qualified names are currently unimplemented."); $$ = nullptr; } // FIX ME
    487487        ;
    488488
     
    10721072mutex_statement:
    10731073        MUTEX '(' argument_expression_list ')' statement
    1074                 { throw SemanticError("Mutex statement is currently unimplemented."); $$ = nullptr; } // FIX ME
     1074                { throw SemanticError(yylloc, "Mutex statement is currently unimplemented."); $$ = nullptr; } // FIX ME
    10751075        ;
    10761076
     
    12931293static_assert:
    12941294        STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11
    1295                 { throw SemanticError("Static assert is currently unimplemented."); $$ = nullptr; }     // FIX ME
     1295                { throw SemanticError(yylloc, "Static assert is currently unimplemented."); $$ = nullptr; }     // FIX ME
    12961296
    12971297// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
     
    23812381                {
    23822382                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    2383                         linkage = LinkageSpec::linkageUpdate( linkage, $2 );
     2383                        linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
    23842384                }
    23852385          '{' external_definition_list_opt '}'
Note: See TracChangeset for help on using the changeset viewer.