Changeset 7c782af for src/Parser


Ignore:
Timestamp:
Feb 16, 2018, 4:22:25 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, stuck-waitfor-destruct, with_gc
Children:
5964127
Parents:
c71b256 (diff), 62cd621 (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:/u/cforall/software/cfa/cfa-cc

Location:
src/Parser
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rc71b256 r7c782af  
    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

    rc71b256 r7c782af  
    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

    rc71b256 r7c782af  
    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

    rc71b256 r7c782af  
    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

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

    rc71b256 r7c782af  
    3131using namespace std;
    3232
    33 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ {
     33TypeData::TypeData( Kind k ) : location( yylloc ), kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ {
    3434        switch ( kind ) {
    3535          case Unknown:
     
    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
     
    800800        assert( td->base );
    801801        if ( td->symbolic.isTypedef ) {
    802                 ret = new TypedefDecl( name, scs, typebuild( td->base ), linkage );
     802                ret = new TypedefDecl( name, td->location, scs, typebuild( td->base ), linkage );
    803803        } else {
    804804                ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Dtype, true );
     
    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/TypeData.h

    rc71b256 r7c782af  
    7676        };
    7777
     78        CodeLocation location;
     79
    7880        Kind kind;
    7981        TypeData * base;
  • src/Parser/parser.yy

    rc71b256 r7c782af  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec 21 11:32:56 2017
    13 // Update Count     : 2996
     12// Last Modified On : Thu Feb 15 17:12:31 2018
     13// Update Count     : 3006
    1414//
    1515
     
    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
     487        | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
     488                { throw SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME
     489        ;
     490
     491generic_assoc_list:                                                                             // C11
     492        | generic_association
     493        | generic_assoc_list ',' generic_association
     494        ;
     495
     496generic_association:                                                                    // C11
     497        type_no_function ':' assignment_expression
     498        | DEFAULT ':' assignment_expression
    487499        ;
    488500
     
    767779        | unary_expression assignment_operator assignment_expression
    768780                { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
     781        | unary_expression '=' '{' initializer_list comma_opt '}' // FIX ME
     782                { $$ = nullptr; }
    769783        ;
    770784
     
    10501064        | RETURN comma_expression_opt ';'
    10511065                { $$ = new StatementNode( build_return( $2 ) ); }
     1066        | RETURN '{' initializer_list comma_opt '}'                     // FIX ME
     1067                { $$ = nullptr; }
    10521068        | THROW assignment_expression_opt ';'                           // handles rethrow
    10531069                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    10681084mutex_statement:
    10691085        MUTEX '(' argument_expression_list ')' statement
    1070                 { throw SemanticError("Mutex statement is currently unimplemented."); $$ = nullptr; } // FIX ME
     1086                { throw SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
    10711087        ;
    10721088
     
    12891305static_assert:
    12901306        STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11
    1291                 { throw SemanticError("Static assert is currently unimplemented."); $$ = nullptr; }     // FIX ME
     1307                { throw SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; }   // FIX ME
    12921308
    12931309// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
     
    23772393                {
    23782394                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    2379                         linkage = LinkageSpec::linkageUpdate( linkage, $2 );
     2395                        linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
    23802396                }
    23812397          '{' external_definition_list_opt '}'
Note: See TracChangeset for help on using the changeset viewer.