Changeset 7c782af for src


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, 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
Files:
1 added
46 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/FixMain.cc

    rc71b256 r7c782af  
    3939        {
    4040                if(main_signature) {
    41                         throw SemanticError("Multiple definition of main routine\n", functionDecl);
     41                        throw SemanticError(functionDecl, "Multiple definition of main routine\n");
    4242                }
    4343                main_signature.reset( functionDecl->clone() );
  • src/CodeGen/FixNames.cc

    rc71b256 r7c782af  
    118118                        int nargs = functionDecl->get_functionType()->get_parameters().size();
    119119                        if( !(nargs == 0 || nargs == 2 || nargs == 3) ) {
    120                                 throw SemanticError("Main expected to have 0, 2 or 3 arguments\n", functionDecl);
     120                                throw SemanticError(functionDecl, "Main expected to have 0, 2 or 3 arguments\n");
    121121                        }
    122122                        functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( new ConstantExpr( Constant::from_int( 0 ) ) ) );
  • src/Common/PassVisitor.impl.h

    rc71b256 r7c782af  
    7777                        maybeAccept_impl( *i, visitor );
    7878                } catch( SemanticError &e ) {
    79                         e.set_location( (*i)->location );
    8079                        errors.append( e );
    8180                }
     
    104103                        maybeMutate_impl( *i, mutator );
    105104                } catch( SemanticError &e ) {
    106                         e.set_location( (*i)->location );
    107105                        errors.append( e );
    108106                }
     
    134132                        }
    135133                } catch( SemanticError &e ) {
    136                         e.set_location( (*i)->location );
    137134                        errors.append( e );
    138135                }
     
    163160                        } // if
    164161                } catch( SemanticError &e ) {
    165                         e.set_location( (*i)->location );
    166162                        errors.append( e );
    167163                } // try
     
    200196
    201197                } catch ( SemanticError &e ) {
    202                         e.set_location( (*i)->location );
    203198                        errors.append( e );
    204199                }
  • src/Common/SemanticError.cc

    rc71b256 r7c782af  
    2323#include "SemanticError.h"
    2424
    25 SemanticError::SemanticError() {
    26 }
    27 
    28 SemanticError::SemanticError( std::string error ) {
    29         append( error );
     25SemanticError::SemanticError( CodeLocation location, std::string error ) {
     26        append( location, error );
    3027}
    3128
     
    3431}
    3532
    36 void SemanticError::append( const std::string & msg ) {
    37         errors.emplace_back( error_str() + msg );
     33void SemanticError::append( CodeLocation location, const std::string & msg ) {
     34        errors.emplace_back( location, msg );
    3835}
    3936
     
    4239}
    4340
    44 void SemanticError::print( std::ostream &os ) {
     41void SemanticError::print() {
    4542        using std::to_string;
    4643        for( auto err : errors ) {
    47                 os << err.location << err.description << std::endl;
     44                std::cerr << bold() << err.location << error_str() << reset_font() << err.description << std::endl;
    4845        }
    4946}
    5047
    51 void SemanticError::set_location( const CodeLocation& location ) {
    52         errors.begin()->maybeSet( location );
     48SemanticWarning::SemanticWarning( CodeLocation location, std::string msg ) {
     49        std::cerr << bold() << location << warning_str() << reset_font() << msg << std::endl;
    5350}
    5451
  • src/Common/SemanticError.h

    rc71b256 r7c782af  
    2424#include "CodeLocation.h"                                                               // for CodeLocation, toString
    2525
     26//-----------------------------------------------------------------------------
     27// Errors
    2628struct error {
     29        CodeLocation location;
    2730        std::string description;
    28         CodeLocation location;
    2931
    3032        error() = default;
    31         error( const std::string & str ) : description( str ) {}
    32 
    33         void maybeSet( const CodeLocation & location ) {
    34                 if( this->location.isUnset() ) {
    35                         this->location = location;
    36                 }
    37         }
     33        error( CodeLocation loc, const std::string & str ) : location( loc ), description( str ) {}
    3834};
    3935
    4036class SemanticError : public std::exception {
    4137  public:
    42         SemanticError();
    43         SemanticError( std::string error );
    44         template< typename T > SemanticError( const std::string & error, const T * obj );
     38        SemanticError() = default;
     39        SemanticError( CodeLocation location, std::string error );
    4540        ~SemanticError() throw() {}
     41
     42        // constructs an exception using the given message and the printed representation of the obj (T must have a print method)
     43        template< typename T > SemanticError(const T * obj, const std::string & error);
     44        template< typename T > SemanticError( CodeLocation location, const T * obj, const std::string & error);
    4645
    4746        static inline const std::string & error_str() {
     
    5150
    5251        void append( SemanticError & other );
    53         void append( const std::string & );
     52        void append( CodeLocation location, const std::string & );
    5453        bool isEmpty() const;
    55         void print( std::ostream & os );
    56 
    57         void set_location( const CodeLocation & location );
    58         // constructs an exception using the given message and the printed representation of the obj (T must have a print
    59         // method)
     54        void print();
    6055  private:
    6156        std::list< error > errors;
     
    6358
    6459template< typename T >
    65 SemanticError::SemanticError( const std::string & error, const T * obj ) {
    66         append( toString( error, obj ) );
     60SemanticError::SemanticError( const T * obj, const std::string & error )
     61        : SemanticError( obj->location, toString( error, obj ) )
     62{}
     63
     64template< typename T >
     65SemanticError::SemanticError( CodeLocation location, const T * obj, const std::string & error )
     66        : SemanticError( location, toString( error, obj ) )
     67{}
     68
     69//-----------------------------------------------------------------------------
     70// Warnings
     71class SemanticWarning {
     72  public:
     73        SemanticWarning( CodeLocation location, std::string error );
     74        ~SemanticWarning() throw() {}
     75
     76        // constructs an exception using the given message and the printed representation of the obj (T must have a print method)
     77        template< typename T > SemanticWarning(const T * obj, const std::string & error);
     78        template< typename T > SemanticWarning( CodeLocation location, const T * obj, const std::string & error);
     79
     80        static inline const std::string & warning_str() {
     81                static std::string str = isatty( STDERR_FILENO ) ? "\e[95mwarning:\e[39m " : "warning: ";
     82                return str;
     83        }
     84
     85  private:
     86};
     87
     88template< typename T >
     89SemanticWarning::SemanticWarning( const T * obj, const std::string & error )
     90        : SemanticWarning( obj->location, toString( error, obj ) )
     91{}
     92
     93template< typename T >
     94SemanticWarning::SemanticWarning( CodeLocation location, const T * obj, const std::string & error )
     95        : SemanticWarning( location, toString( error, obj ) )
     96{}
     97
     98//-----------------------------------------------------------------------------
     99// Helpers
     100static inline const std::string & bold_ttycode() {
     101        static std::string str = isatty( STDERR_FILENO ) ? "\e[1m" : "";
     102        return str;
     103}
     104
     105static inline const std::string & reset_font_ttycode() {
     106        static std::string str = isatty( STDERR_FILENO ) ? "\e[0m" : "";
     107        return str;
     108}
     109
     110static inline std::string make_bold( const std::string & str ) {
     111        return bold_ttycode() + str + reset_font_ttycode();
     112}
     113
     114struct bold {};
     115static inline std::ostream & operator<<(std::ostream & os, bold) {
     116        os << bold_ttycode();
     117        return os;
     118}
     119
     120struct reset_font {};
     121static inline std::ostream & operator<<(std::ostream & os, reset_font) {
     122        os << reset_font_ttycode();
     123        return os;
    67124}
    68125
  • src/Concurrency/Keywords.cc

    rc71b256 r7c782af  
    276276                        handle( decl );
    277277                }
    278 
    279278        }
    280279
     
    282281                if( ! decl->body ) return;
    283282
    284                 if( !type_decl ) throw SemanticError( context_error, decl );
     283                if( !type_decl ) throw SemanticError( decl, context_error );
    285284
    286285                FunctionDecl * func = forwardDeclare( decl );
     
    419418                if( mutexArgs.empty() ) return;
    420419
    421                 if( CodeGen::isConstructor(decl->name) ) throw SemanticError( "constructors cannot have mutex parameters", decl );
     420                if( CodeGen::isConstructor(decl->name) ) throw SemanticError( decl, "constructors cannot have mutex parameters" );
    422421
    423422                bool isDtor = CodeGen::isDestructor( decl->name );
    424423
    425                 if( isDtor && mutexArgs.size() != 1 ) throw SemanticError( "destructors can only have 1 mutex argument", decl );
     424                if( isDtor && mutexArgs.size() != 1 ) throw SemanticError( decl, "destructors can only have 1 mutex argument" );
    426425
    427426                for(auto arg : mutexArgs) {
     
    432431                if( ! body ) return;
    433432
    434                 if( !monitor_decl ) throw SemanticError( "mutex keyword requires monitors to be in scope, add #include <monitor>", decl );
    435                 if( !guard_decl ) throw SemanticError( "mutex keyword requires monitors to be in scope, add #include <monitor>", decl );
    436                 if( !dtor_guard_decl ) throw SemanticError( "mutex keyword requires monitors to be in scope, add #include <monitor>", decl );
     433                if( !monitor_decl ) throw SemanticError( decl, "mutex keyword requires monitors to be in scope, add #include <monitor>" );
     434                if( !guard_decl ) throw SemanticError( decl, "mutex keyword requires monitors to be in scope, add #include <monitor>" );
     435                if( !dtor_guard_decl ) throw SemanticError( decl, "mutex keyword requires monitors to be in scope, add #include <monitor>" );
    437436
    438437                if( isDtor ) {
     
    480479                //Makes sure it's not a copy
    481480                ReferenceType* rty = dynamic_cast< ReferenceType * >( ty );
    482                 if( ! rty ) throw SemanticError( "Mutex argument must be of reference type ", arg );
     481                if( ! rty ) throw SemanticError( arg, "Mutex argument must be of reference type " );
    483482
    484483                //Make sure the we are pointing directly to a type
    485484                Type* base = rty->get_base();
    486                 if( dynamic_cast< ReferenceType * >( base ) ) throw SemanticError( "Mutex argument have exactly one level of indirection ", arg );
    487                 if( dynamic_cast< PointerType * >( base ) ) throw SemanticError( "Mutex argument have exactly one level of indirection ", arg );
     485                if( dynamic_cast< ReferenceType * >( base ) ) throw SemanticError( arg, "Mutex argument have exactly one level of indirection " );
     486                if( dynamic_cast< PointerType * >( base ) ) throw SemanticError( arg, "Mutex argument have exactly one level of indirection " );
    488487
    489488                //Make sure that typed isn't mutex
    490                 if( base->get_mutex() ) throw SemanticError( "mutex keyword may only appear once per argument ", arg );
     489                if( base->get_mutex() ) throw SemanticError( arg, "mutex keyword may only appear once per argument " );
    491490        }
    492491
     
    626625                if( type && type->get_baseStruct()->is_thread() ) {
    627626                        if( !thread_decl || !thread_ctor_seen ) {
    628                                 throw SemanticError("thread keyword requires threads to be in scope, add #include <thread>");
     627                                throw SemanticError( type->get_baseStruct()->location, "thread keyword requires threads to be in scope, add #include <thread>");
    629628                        }
    630629
  • src/Concurrency/Waitfor.cc

    rc71b256 r7c782af  
    249249
    250250        Statement * GenerateWaitForPass::postmutate( WaitForStmt * waitfor ) {
    251                 if( !decl_monitor || !decl_acceptable || !decl_mask ) throw SemanticError( "waitfor keyword requires monitors to be in scope, add #include <monitor>", waitfor );
     251                if( !decl_monitor || !decl_acceptable || !decl_mask )
     252                        throw SemanticError( waitfor, "waitfor keyword requires monitors to be in scope, add #include <monitor>" );
    252253
    253254                CompoundStmt * stmt = new CompoundStmt();
  • src/ControlStruct/ExceptTranslate.cc

    rc71b256 r7c782af  
    572572                        // Pass.
    573573                } else if ( CatchStmt::Terminate == catchStmt->get_kind() ) {
    574                         throw SemanticError("catch must have exception type");
     574                        throw SemanticError(catchStmt->location, "catch must have exception type");
    575575                } else {
    576                         throw SemanticError("catchResume must have exception type");
     576                        throw SemanticError(catchStmt->location, "catchResume must have exception type");
    577577                }
    578578
  • src/ControlStruct/LabelFixer.cc

    rc71b256 r7c782af  
    9292                        } else if ( labelTable[ l ]->defined() ) {
    9393                                // defined twice, error
    94                                 throw SemanticError( "Duplicate definition of label: " + l.get_name() );
     94                                throw SemanticError( l.get_statement()->location, "Duplicate definition of label: " + l.get_name() );
    9595                        }       else {
    9696                                // used previously, but undefined until now -> link with this entry
     
    121121                for ( std::map< Label, Entry * >::iterator i = labelTable.begin(); i != labelTable.end(); ++i ) {
    122122                        if ( ! i->second->defined() ) {
    123                                 throw SemanticError( "Use of undefined label: " + i->first.get_name() );
     123                                throw SemanticError( i->first.get_statement()->location, "Use of undefined label: " + i->first.get_name() );
    124124                        }
    125125                        (*ret)[ i->first ] = i->second->get_definition();
  • src/ControlStruct/MLEMutator.cc

    rc71b256 r7c782af  
    115115                                        } else {
    116116                                                // break target is outmost control structure
    117                                                 if ( enclosingControlStructures.empty() ) throw SemanticError( "'break' outside a loop, switch, or labelled block" );
     117                                                if ( enclosingControlStructures.empty() ) throw SemanticError( branchStmt->location, "'break' outside a loop, switch, or labelled block" );
    118118                                                targetEntry = enclosingControlStructures.rbegin();
    119119                                        } // if
     
    124124                                // ensure that selected target is valid
    125125                                if ( targetEntry == enclosingControlStructures.rend() || (isContinue && ! isLoop( targetEntry->get_controlStructure() ) ) ) {
    126                                         throw SemanticError( toString( (isContinue ? "'continue'" : "'break'"), " target must be an enclosing ", (isContinue ? "loop: " : "control structure: "), originalTarget ) );
     126                                        throw SemanticError( branchStmt->location, toString( (isContinue ? "'continue'" : "'break'"), " target must be an enclosing ", (isContinue ? "loop: " : "control structure: "), originalTarget ) );
    127127                                } // if
    128128                                break;
  • src/GenPoly/Box.cc

    rc71b256 r7c782af  
    229229                                } // if
    230230                        } catch( SemanticError &e ) {
    231                                 e.set_location( (*i)->location );
    232231                                errors.append( e );
    233232                        } // try
     
    576575                                                }
    577576                                        } else {
    578                                                 throw SemanticError( "Cannot pass non-struct type for generic struct: ", argBaseType );
     577                                                throw SemanticError( argBaseType, "Cannot pass non-struct type for generic struct: " );
    579578                                        }
    580579                                }
     
    598597                                        } else {
    599598                                                // xxx - should this be an assertion?
    600                                                 throw SemanticError( toString( *env, "\nunbound type variable: ", tyParm->first, " in application " ), appExpr );
     599                                                throw SemanticError( appExpr, toString( *env, "\nunbound type variable: ", tyParm->first, " in application " ) );
    601600                                        } // if
    602601                                } // if
  • src/InitTweak/FixInit.cc

    rc71b256 r7c782af  
    282282                                        translationUnit.splice( i, fixer.pass.staticDtorDecls );
    283283                                } catch( SemanticError &e ) {
    284                                         e.set_location( (*i)->location );
    285284                                        errors.append( e );
    286285                                } // try
     
    895894                        )
    896895                        if ( ! diff.empty() ) {
    897                                 throw SemanticError( std::string("jump to label '") + stmt->get_target().get_name() + "' crosses initialization of " + (*diff.begin())->get_name() + " ", stmt );
     896                                throw SemanticError( stmt, std::string("jump to label '") + stmt->get_target().get_name() + "' crosses initialization of " + (*diff.begin())->get_name() + " " );
    898897                        } // if
    899898                        // S_G-S_L results in set of objects that must be destructed
     
    11111110                template< typename Visitor, typename... Params >
    11121111                void error( Visitor & v, CodeLocation loc, const Params &... params ) {
    1113                         SemanticError err( toString( params... ) );
    1114                         err.set_location( loc );
     1112                        SemanticError err( loc, toString( params... ) );
    11151113                        v.errors.append( err );
    11161114                }
  • src/InitTweak/GenInit.cc

    rc71b256 r7c782af  
    317317                if ( tryConstruct( objDecl ) && ( managedTypes.isManaged( objDecl ) || ((! inFunction || objDecl->get_storageClasses().is_static ) && ! isConstExpr( objDecl->get_init() ) ) ) ) {
    318318                        // constructed objects cannot be designated
    319                         if ( isDesignated( objDecl->get_init() ) ) throw SemanticError( "Cannot include designations in the initializer for a managed Object. If this is really what you want, then initialize with @=.\n", objDecl );
     319                        if ( isDesignated( objDecl->get_init() ) ) throw SemanticError( objDecl, "Cannot include designations in the initializer for a managed Object. If this is really what you want, then initialize with @=.\n" );
    320320                        // constructed objects should not have initializers nested too deeply
    321                         if ( ! checkInitDepth( objDecl ) ) throw SemanticError( "Managed object's initializer is too deep ", objDecl );
     321                        if ( ! checkInitDepth( objDecl ) ) throw SemanticError( objDecl, "Managed object's initializer is too deep " );
    322322
    323323                        objDecl->set_init( genCtorInit( objDecl ) );
  • src/InitTweak/InitTweak.cc

    rc71b256 r7c782af  
    225225                                        // xxx - this shouldn't be an error, but need a way to
    226226                                        // terminate without creating output, so should catch this error
    227                                         throw SemanticError( "unbalanced list initializers" );
     227                                        throw SemanticError( init->location, "unbalanced list initializers" );
    228228                                }
    229229
  • 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 '}'
  • src/ResolvExpr/AlternativeFinder.cc

    rc71b256 r7c782af  
    239239                                std::cerr << "No reasonable alternatives for expression " << expr << std::endl;
    240240                        )
    241                         throw SemanticError( "No reasonable alternatives for expression ", expr );
     241                        throw SemanticError( expr, "No reasonable alternatives for expression " );
    242242                }
    243243                if ( prune ) {
     
    257257                                stream << "Alternatives are:\n";
    258258                                printAlts( winners, stream, 1 );
    259                                 throw SemanticError( stream.str() );
     259                                throw SemanticError( expr->location, stream.str() );
    260260                        }
    261261                        alternatives = move(pruned);
     
    494494                                return;
    495495                        } else if ( level >= recursionLimit ) {
    496                                 throw SemanticError( "Too many recursive assertions" );
     496                                throw SemanticError( newAlt.expr->location, "Too many recursive assertions" );
    497497                        } else {
    498498                                AssertionSet newerNeed;
     
    14081408                        findMinCost( finder.alternatives.begin(), finder.alternatives.end(), back_inserter( winners ) );
    14091409                        if ( winners.size() != 1 ) {
    1410                                 throw SemanticError( "Ambiguous expression in sizeof operand: ", sizeofExpr->get_expr() );
     1410                                throw SemanticError( sizeofExpr->get_expr(), "Ambiguous expression in sizeof operand: " );
    14111411                        } // if
    14121412                        // return the lowest cost alternative for the argument
     
    14291429                        findMinCost( finder.alternatives.begin(), finder.alternatives.end(), back_inserter( winners ) );
    14301430                        if ( winners.size() != 1 ) {
    1431                                 throw SemanticError( "Ambiguous expression in alignof operand: ", alignofExpr->get_expr() );
     1431                                throw SemanticError( alignofExpr->get_expr(), "Ambiguous expression in alignof operand: " );
    14321432                        } // if
    14331433                        // return the lowest cost alternative for the argument
  • src/ResolvExpr/CurrentObject.cc

    rc71b256 r7c782af  
    141141                        base = at->get_base();
    142142                        memberIter = createMemberIterator( base );
    143                         if ( at->isVarLen ) throw SemanticError( "VLA initialization does not support @=", at );
     143                        if ( at->isVarLen ) throw SemanticError( at, "VLA initialization does not support @=" );
    144144                        setSize( at->get_dimension() );
    145145                }
     
    156156                                        PRINT( std::cerr << "array type with size: " << size << std::endl; )
    157157                                } catch ( SemanticError & ) {
    158                                         throw SemanticError( "Constant expression of non-integral type in array dimension: ", expr );
     158                                        throw SemanticError( expr, "Constant expression of non-integral type in array dimension: " );
    159159                                }
    160160                        }       else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
     
    179179                                        index = constExpr->intValue();
    180180                                } catch( SemanticError & ) {
    181                                         throw SemanticError( "Constant expression of non-integral type in array designator: ", expr );
     181                                        throw SemanticError( expr, "Constant expression of non-integral type in array designator: " );
    182182                                }
    183183                        } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
     
    532532                } // for
    533533                if ( desigAlts.size() > 1 ) {
    534                         throw SemanticError( toString("Too many alternatives (", desigAlts.size(), ") for designation: "), designation );
     534                        throw SemanticError( designation, toString("Too many alternatives (", desigAlts.size(), ") for designation: ") );
    535535                } else if ( desigAlts.size() == 0 ) {
    536                         throw SemanticError( "No reasonable alternatives for designation: ", designation );
     536                        throw SemanticError( designation, "No reasonable alternatives for designation: " );
    537537                }
    538538                DesignatorChain & d = desigAlts.back();
  • src/ResolvExpr/Resolver.cc

    rc71b256 r7c782af  
    174174                        findMinCost( candidates.begin(), candidates.end(), back_inserter( winners ) );
    175175                        if ( winners.size() == 0 ) {
    176                                 throw SemanticError( toString( "No reasonable alternatives for ", kindStr, (kindStr != "" ? " " : ""), "expression: "), untyped );
     176                                throw SemanticError( untyped, toString( "No reasonable alternatives for ", kindStr, (kindStr != "" ? " " : ""), "expression: ") );
    177177                        } else if ( winners.size() != 1 ) {
    178178                                std::ostringstream stream;
     
    181181                                stream << "Alternatives are:\n";
    182182                                printAlts( winners, stream, 1 );
    183                                 throw SemanticError( stream.str() );
     183                                throw SemanticError( untyped->location, stream.str() );
    184184                        }
    185185
     
    187187                        Alternative & choice = winners.front();
    188188                        if ( findDeletedExpr( choice.expr ) ) {
    189                                 throw SemanticError( "Unique best alternative includes deleted identifier in ", choice.expr );
     189                                throw SemanticError( choice.expr, "Unique best alternative includes deleted identifier in " );
    190190                        }
    191191                        alt = std::move( choice );
     
    484484                                ss << strict_dynamic_cast<NameExpr*>( clause.target.function )->name;
    485485                                ss << "' in call to waitfor";
    486                                 throw SemanticError( ss.str() );
     486                                throw SemanticError( stmt->location, ss.str() );
    487487                        }
    488488
     
    506506                                        PointerType * pointer = dynamic_cast< PointerType* >( func.expr->get_result()->stripReferences() );
    507507                                        if( !pointer ) {
    508                                                 throw SemanticError( "candidate not viable: not a pointer type\n", func.expr->get_result() );
     508                                                throw SemanticError( func.expr->get_result(), "candidate not viable: not a pointer type\n" );
    509509                                        }
    510510
    511511                                        FunctionType * function = dynamic_cast< FunctionType* >( pointer->get_base() );
    512512                                        if( !function ) {
    513                                                 throw SemanticError( "candidate not viable: not a function type\n", pointer->get_base() );
     513                                                throw SemanticError( pointer->get_base(), "candidate not viable: not a function type\n" );
    514514                                        }
    515515
     
    520520
    521521                                                if( !advance_to_mutex( param, param_end ) ) {
    522                                                         throw SemanticError("candidate function not viable: no mutex parameters\n", function);
     522                                                        throw SemanticError(function, "candidate function not viable: no mutex parameters\n");
    523523                                                }
    524524                                        }
     
    559559                                                                        // We ran out of parameters but still have arguments
    560560                                                                        // this function doesn't match
    561                                                                         throw SemanticError("candidate function not viable: too many mutex arguments\n", function);
     561                                                                        throw SemanticError( function, "candidate function not viable: too many mutex arguments\n" );
    562562                                                                }
    563563
     
    571571                                                                        (*param)->get_type()->print( ss );
    572572                                                                        ss << "'\n";
    573                                                                         throw SemanticError(ss.str(), function);
     573                                                                        throw SemanticError( function, ss.str() );
    574574                                                                }
    575575
     
    583583                                                                // We ran out of arguments but still have parameters left
    584584                                                                // this function doesn't match
    585                                                                 throw SemanticError("candidate function not viable: too few mutex arguments\n", function);
     585                                                                throw SemanticError( function, "candidate function not viable: too few mutex arguments\n" );
    586586                                                        }
    587587
     
    610610
    611611                        // Make sure we got the right number of arguments
    612                         if( func_candidates.empty() )    { SemanticError top( "No alternatives for function in call to waitfor"  ); top.append( errors ); throw top; }
    613                         if( args_candidates.empty() )    { SemanticError top( "No alternatives for arguments in call to waitfor" ); top.append( errors ); throw top; }
    614                         if( func_candidates.size() > 1 ) { SemanticError top( "Ambiguous function in call to waitfor"            ); top.append( errors ); throw top; }
    615                         if( args_candidates.size() > 1 ) { SemanticError top( "Ambiguous arguments in call to waitfor"           ); top.append( errors ); throw top; }
     612                        if( func_candidates.empty() )    { SemanticError top( stmt->location, "No alternatives for function in call to waitfor"  ); top.append( errors ); throw top; }
     613                        if( args_candidates.empty() )    { SemanticError top( stmt->location, "No alternatives for arguments in call to waitfor" ); top.append( errors ); throw top; }
     614                        if( func_candidates.size() > 1 ) { SemanticError top( stmt->location, "Ambiguous function in call to waitfor"            ); top.append( errors ); throw top; }
     615                        if( args_candidates.size() > 1 ) { SemanticError top( stmt->location, "Ambiguous arguments in call to waitfor"           ); top.append( errors ); throw top; }
    616616                        // TODO: need to use findDeletedExpr to ensure no deleted identifiers are used.
    617617
  • src/SymTab/Indexer.cc

    rc71b256 r7c782af  
    443443                        // isomorphic to C type-compatibility, which it may not be.
    444444                        if ( hasIncompatibleCDecl( name, mangleName, scope ) ) {
    445                                 throw SemanticError( "conflicting overload of C function ", decl );
     445                                throw SemanticError( decl, "conflicting overload of C function " );
    446446                        }
    447447                } else {
    448448                        // Check that a Cforall declaration doesn't override any C declaration
    449449                        if ( hasCompatibleCDecl( name, mangleName, scope ) ) {
    450                                 throw SemanticError( "Cforall declaration hides C function ", decl );
     450                                throw SemanticError( decl, "Cforall declaration hides C function " );
    451451                        }
    452452                }
     
    463463        void Indexer::addId( DeclarationWithType * decl, Expression * baseExpr ) {
    464464                // default handling of conflicts is to raise an error
    465                 addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( msg, decl ); return true; }, baseExpr );
     465                addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( decl, msg ); return true; }, baseExpr );
    466466        }
    467467
    468468        void Indexer::addDeletedId( DeclarationWithType * decl, BaseSyntaxNode * deleteStmt ) {
    469469                // default handling of conflicts is to raise an error
    470                 addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( msg, decl ); return true; }, nullptr, deleteStmt );
     470                addId( decl, [decl](IdData &, const std::string & msg) { throw SemanticError( decl, msg ); return true; }, nullptr, deleteStmt );
    471471        }
    472472
     
    477477                        return true;
    478478                } else {
    479                         throw SemanticError( "redeclaration of ", added );
     479                        throw SemanticError( added, "redeclaration of " );
    480480                }
    481481        }
     
    504504                        return false;
    505505                } else if ( ! added->get_members().empty() ) {
    506                         throw SemanticError( "redeclaration of ", added );
     506                        throw SemanticError( added, "redeclaration of " );
    507507                } // if
    508508                return true;
  • src/SymTab/Validate.cc

    rc71b256 r7c782af  
    361361                        // the only case in which "void" is valid is where it is the only one in the list
    362362                        if ( containsVoid && ( nvals > 1 || isVarArgs ) ) {
    363                                 throw SemanticError( "invalid type void in function type ", func );
     363                                throw SemanticError( func, "invalid type void in function type " );
    364364                        }
    365365
     
    402402                for ( Expression * param : inst->parameters ) {
    403403                        if ( ! dynamic_cast< TypeExpr * >( param ) ) {
    404                                 throw SemanticError( "Expression parameters for generic types are currently unsupported: ", inst );
     404                                throw SemanticError( inst, "Expression parameters for generic types are currently unsupported: " );
    405405                        }
    406406                }
     
    502502                TraitDecl *traitDecl = local_indexer->lookupTrait( traitInst->name );
    503503                if ( ! traitDecl ) {
    504                         throw SemanticError( "use of undeclared trait " + traitInst->name );
     504                        throw SemanticError( traitInst->location, "use of undeclared trait " + traitInst->name );
    505505                } // if
    506506                if ( traitDecl->get_parameters().size() != traitInst->get_parameters().size() ) {
    507                         throw SemanticError( "incorrect number of trait parameters: ", traitInst );
     507                        throw SemanticError( traitInst, "incorrect number of trait parameters: " );
    508508                } // if
    509509                traitInst->baseTrait = traitDecl;
     
    513513                        TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) );
    514514                        if ( ! expr ) {
    515                                 throw SemanticError( "Expression parameters for trait instances are currently unsupported: ", std::get<1>(p) );
     515                                throw SemanticError( std::get<1>(p), "Expression parameters for trait instances are currently unsupported: " );
    516516                        }
    517517                        if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) {
     
    619619                                bool isVoid = fixFunction( assertion );
    620620                                if ( isVoid ) {
    621                                         throw SemanticError( "invalid type void in assertion of function ", node );
     621                                        throw SemanticError( node, "invalid type void in assertion of function " );
    622622                                } // if
    623623                        } // for
     
    663663                // were cast to void.
    664664                if ( ! returnStmt->get_expr() && returnVals.size() != 0 ) {
    665                         throw SemanticError( "Non-void function returns no values: " , returnStmt );
     665                        throw SemanticError( returnStmt, "Non-void function returns no values: " );
    666666                }
    667667        }
     
    704704                                ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret);
    705705                                if ( ! rtt ) {
    706                                         throw SemanticError("Cannot apply type parameters to base type of " + typeInst->name);
     706                                        throw SemanticError( typeInst->location, "Cannot apply type parameters to base type of " + typeInst->name );
    707707                                }
    708708                                rtt->get_parameters().clear();
     
    742742                        Type * t2 = typedefNames[ tyDecl->get_name() ].first->get_base();
    743743                        if ( ! ResolvExpr::typesCompatible( t1, t2, Indexer() ) ) {
    744                                 throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );
     744                                throw SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );
    745745                        }
    746746                        // Cannot redefine VLA typedefs. Note: this is slightly incorrect, because our notion of VLAs
     
    749749                        // to fix this corner case likely outweighs the utility of allowing it.
    750750                        if ( isVariableLength( t1 ) || isVariableLength( t2 ) ) {
    751                                 throw SemanticError( "Cannot redefine typedef: " + tyDecl->name );
     751                                throw SemanticError( tyDecl->location, "Cannot redefine typedef: " + tyDecl->name );
    752752                        }
    753753                } else {
     
    847847                                type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() );
    848848                        } // if
    849                         TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), Type::StorageClasses(), type, aggDecl->get_linkage() ) );
     849                        TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), aggDecl->location, Type::StorageClasses(), type, aggDecl->get_linkage() ) );
    850850                        typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel );
    851851                } // if
     
    898898                if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc.
    899899                        if ( params.size() == 0 ) {
    900                                 throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl );
     900                                throw SemanticError( funcDecl, "Constructors, destructors, and assignment functions require at least one parameter " );
    901901                        }
    902902                        ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() );
    903903                        if ( ! refType ) {
    904                                 throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a reference ", funcDecl );
     904                                throw SemanticError( funcDecl, "First parameter of a constructor, destructor, or assignment function must be a reference " );
    905905                        }
    906906                        if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {
    907                                 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl );
     907                                throw SemanticError( funcDecl, "Constructors and destructors cannot have explicit return values " );
    908908                        }
    909909                }
     
    940940
    941941                        sub.apply( inst );
    942                         if ( args.size() < params->size() ) throw SemanticError( "Too few type arguments in generic type ", inst );
    943                         if ( args.size() > params->size() ) throw SemanticError( "Too many type arguments in generic type ", inst );
     942                        if ( args.size() < params->size() ) throw SemanticError( inst, "Too few type arguments in generic type " );
     943                        if ( args.size() > params->size() ) throw SemanticError( inst, "Too many type arguments in generic type " );
    944944                }
    945945        }
  • src/SynTree/Declaration.h

    rc71b256 r7c782af  
    245245        typedef NamedTypeDecl Parent;
    246246  public:
    247         TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall ) : Parent( name, scs, type ) { set_linkage( spec ); }
     247        TypedefDecl( const std::string &name, CodeLocation location, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall )
     248                : Parent( name, scs, type ) { set_linkage( spec ); this->location = location; }
     249
    248250        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    249251
  • src/SynTree/Expression.cc

    rc71b256 r7c782af  
    9393                return 0;
    9494        }
    95         throw SemanticError( "Constant expression of non-integral type ", this );
     95        throw SemanticError( this, "Constant expression of non-integral type " );
    9696}
    9797
  • src/SynTree/Mutator.h

    rc71b256 r7c782af  
    149149                        } // if
    150150                } catch( SemanticError &e ) {
    151                         e.set_location( (*i)->location );
    152151                        errors.append( e );
    153152                } // try
  • src/SynTree/Statement.cc

    rc71b256 r7c782af  
    100100        //actually this is a syntactic error signaled by the parser
    101101        if ( type == BranchStmt::Goto && target.empty() ) {
    102                 throw SemanticError("goto without target");
     102                throw SemanticError( target.get_statement()->location, "goto without target");
    103103        }
    104104}
     
    107107        Statement(), computedTarget( computedTarget ), type( type ) {
    108108        if ( type != BranchStmt::Goto || computedTarget == nullptr ) {
    109                 throw SemanticError("Computed target not valid in branch statement");
     109                throw SemanticError( computedTarget->location, "Computed target not valid in branch statement");
    110110        }
    111111}
     
    203203CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :
    204204        Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {
    205         if ( isDefault() && condition != 0 ) throw SemanticError("default case with condition: ", condition);
     205        if ( isDefault() && condition != 0 ) throw SemanticError( condition, "default case with condition: " );
    206206}
    207207
  • src/SynTree/TypeSubstitution.h

    rc71b256 r7c782af  
    9898                                } // if
    9999                        } else {
    100                                 throw SemanticError( toString( "Attempt to provide non-type parameter: ", toString( *actualIt ).c_str(), " for type parameter " ), formal );
     100                                throw SemanticError( formal, toString( "Attempt to provide non-type parameter: ", toString( *actualIt ).c_str(), " for type parameter " ) );
    101101                        } // if
    102102                } else {
  • src/SynTree/Visitor.h

    rc71b256 r7c782af  
    143143                        }
    144144                } catch( SemanticError &e ) {
    145                         e.set_location( (*i)->location );
    146145                        errors.append( e );
    147146                }
  • src/libcfa/concurrency/alarm.c

    rc71b256 r7c782af  
    1818#include <stdio.h>
    1919#include <string.h>
    20 #include <time.h>
    2120#include <unistd.h>
    2221#include <sys/time.h>
     
    2726#include "preemption.h"
    2827
    29 //=============================================================================================
    30 // time type
    31 //=============================================================================================
    3228
    33 #define one_second         1_000_000_000ul
    34 #define one_milisecond         1_000_000ul
    35 #define one_microsecond            1_000ul
    36 #define one_nanosecond                 1ul
    37 
    38 __cfa_time_t zero_time = { 0 };
    39 
    40 void ?{}( __cfa_time_t & this ) { this.val = 0; }
    41 void ?{}( __cfa_time_t & this, zero_t zero ) { this.val = 0; }
    42 
    43 void ?{}( itimerval & this, __cfa_time_t * alarm ) with( this ) {
    44         it_value.tv_sec = alarm->val / one_second;                      // seconds
    45         it_value.tv_usec = max( (alarm->val % one_second) / one_microsecond, 1000 ); // microseconds
     29static inline void ?{}( itimerval & this, __cfa_time_t * alarm ) with( this ) {
     30        it_value.tv_sec = alarm->val / (1`cfa_s).val;                   // seconds
     31        it_value.tv_usec = max( (alarm->val % (1`cfa_s).val) / (1`cfa_us).val, 1000 ); // microseconds
    4632        it_interval.tv_sec = 0;
    4733        it_interval.tv_usec = 0;
    4834}
    4935
    50 
    51 void ?{}( __cfa_time_t & this, timespec * curr ) {
     36static inline void ?{}( __cfa_time_t & this, timespec * curr ) {
    5237        uint64_t secs  = curr->tv_sec;
    5338        uint64_t nsecs = curr->tv_nsec;
    54         this.val = (secs * one_second) + nsecs;
     39        this.val = from_s(secs).val + nsecs;
    5540}
    56 
    57 __cfa_time_t ?=?( __cfa_time_t & this, zero_t rhs ) {
    58         this.val = 0;
    59         return this;
    60 }
    61 
    62 __cfa_time_t from_s ( uint64_t val ) { __cfa_time_t ret; ret.val = val * 1_000_000_000ul; return ret; }
    63 __cfa_time_t from_ms( uint64_t val ) { __cfa_time_t ret; ret.val = val *     1_000_000ul; return ret; }
    64 __cfa_time_t from_us( uint64_t val ) { __cfa_time_t ret; ret.val = val *         1_000ul; return ret; }
    65 __cfa_time_t from_ns( uint64_t val ) { __cfa_time_t ret; ret.val = val *             1ul; return ret; }
    6641
    6742//=============================================================================================
     
    8459//=============================================================================================
    8560
    86 void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = zero_time, __cfa_time_t period = zero_time ) with( this ) {
     61void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s ) with( this ) {
    8762        this.thrd = thrd;
    8863        this.alarm = alarm;
     
    9368}
    9469
    95 void ?{}( alarm_node_t & this, processor   * proc, __cfa_time_t alarm = zero_time, __cfa_time_t period = zero_time ) with( this ) {
     70void ?{}( alarm_node_t & this, processor   * proc, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s ) with( this ) {
    9671        this.proc = proc;
    9772        this.alarm = alarm;
  • src/libcfa/concurrency/alarm.h

    rc71b256 r7c782af  
    2121#include <assert.h>
    2222
     23#include "bits/cfatime.h"
     24
    2325struct thread_desc;
    2426struct processor;
    25 
    26 struct timespec;
    27 struct itimerval;
    28 
    29 //=============================================================================================
    30 // time type
    31 //=============================================================================================
    32 
    33 struct __cfa_time_t {
    34         uint64_t val;
    35 };
    36 
    37 // ctors
    38 void ?{}( __cfa_time_t & this );
    39 void ?{}( __cfa_time_t & this, zero_t zero );
    40 void ?{}( __cfa_time_t & this, timespec * curr );
    41 void ?{}( itimerval & this, __cfa_time_t * alarm );
    42 
    43 __cfa_time_t ?=?( __cfa_time_t & this, zero_t rhs );
    44 
    45 // logical ops
    46 static inline bool ?==?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val == rhs.val; }
    47 static inline bool ?!=?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val != rhs.val; }
    48 static inline bool ?>? ( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val >  rhs.val; }
    49 static inline bool ?<? ( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val <  rhs.val; }
    50 static inline bool ?>=?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val >= rhs.val; }
    51 static inline bool ?<=?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val <= rhs.val; }
    52 
    53 static inline bool ?==?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val == rhs; }
    54 static inline bool ?!=?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val != rhs; }
    55 static inline bool ?>? ( __cfa_time_t lhs, zero_t rhs ) { return lhs.val >  rhs; }
    56 static inline bool ?<? ( __cfa_time_t lhs, zero_t rhs ) { return lhs.val <  rhs; }
    57 static inline bool ?>=?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val >= rhs; }
    58 static inline bool ?<=?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val <= rhs; }
    59 
    60 // addition/substract
    61 static inline __cfa_time_t ?+?( __cfa_time_t lhs, __cfa_time_t rhs ) {
    62         __cfa_time_t ret;
    63         ret.val = lhs.val + rhs.val;
    64         return ret;
    65 }
    66 
    67 static inline __cfa_time_t ?-?( __cfa_time_t lhs, __cfa_time_t rhs ) {
    68         __cfa_time_t ret;
    69         ret.val = lhs.val - rhs.val;
    70         return ret;
    71 }
    72 
    73 __cfa_time_t from_s ( uint64_t );
    74 __cfa_time_t from_ms( uint64_t );
    75 __cfa_time_t from_us( uint64_t );
    76 __cfa_time_t from_ns( uint64_t );
    77 
    78 extern __cfa_time_t zero_time;
    7927
    8028//=============================================================================================
     
    10553typedef alarm_node_t ** __alarm_it_t;
    10654
    107 void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = zero_time, __cfa_time_t period = zero_time );
    108 void ?{}( alarm_node_t & this, processor   * proc, __cfa_time_t alarm = zero_time, __cfa_time_t period = zero_time );
     55void ?{}( alarm_node_t & this, thread_desc * thrd, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s );
     56void ?{}( alarm_node_t & this, processor   * proc, __cfa_time_t alarm = 0`cfa_s, __cfa_time_t period = 0`cfa_s );
    10957void ^?{}( alarm_node_t & this );
    11058
  • src/libcfa/concurrency/coroutine.c

    rc71b256 r7c782af  
    9999// Wrapper for co
    100100void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
     101        verify( preemption.enabled || this_processor->do_terminate );
    101102        disable_interrupts();
    102103
     
    116117
    117118        enable_interrupts( __cfaabi_dbg_ctx );
     119        verify( preemption.enabled || this_processor->do_terminate );
    118120} //ctxSwitchDirect
    119121
  • src/libcfa/concurrency/invoke.c

    rc71b256 r7c782af  
    2828extern void __suspend_internal(void);
    2929extern void __leave_coroutine(void);
     30extern void __finish_creation(void);
    3031extern void __leave_thread_monitor( struct thread_desc * this );
    3132extern void disable_interrupts();
     
    4445
    4546        cor->state = Active;
     47
     48        enable_interrupts( __cfaabi_dbg_ctx );
    4649
    4750        main( this );
     
    6265        // First suspend, once the thread arrives here,
    6366        // the function pointer to main can be invalidated without risk
    64         __suspend_internal();
     67        __finish_creation();
    6568
    6669        // Fetch the thread handle from the user defined thread structure
  • src/libcfa/concurrency/kernel.c

    rc71b256 r7c782af  
    5656thread_local processor *      volatile this_processor;
    5757
    58 volatile thread_local bool preemption_in_progress = 0;
    59 volatile thread_local bool preemption_enabled = false;
    60 volatile thread_local unsigned short disable_preempt_count = 1;
     58// volatile thread_local bool preemption_in_progress = 0;
     59// volatile thread_local bool preemption_enabled = false;
     60// volatile thread_local unsigned short disable_preempt_count = 1;
     61
     62volatile thread_local __cfa_kernel_preemption_data_t preemption = { false, false, 1 };
    6163
    6264//-----------------------------------------------------------------------------
     
    207209                        if(readyThread)
    208210                        {
    209                                 verify( !preemption_enabled );
     211                                verify( !preemption.enabled );
    210212
    211213                                runThread(this, readyThread);
    212214
    213                                 verify( !preemption_enabled );
     215                                verify( !preemption.enabled );
    214216
    215217                                //Some actions need to be taken from the kernel
     
    260262void finishRunning(processor * this) with( this->finish ) {
    261263        if( action_code == Release ) {
    262                 verify( !preemption_enabled );
     264                verify( !preemption.enabled );
    263265                unlock( *lock );
    264266        }
     
    267269        }
    268270        else if( action_code == Release_Schedule ) {
    269                 verify( !preemption_enabled );
     271                verify( !preemption.enabled );
    270272                unlock( *lock );
    271273                ScheduleThread( thrd );
    272274        }
    273275        else if( action_code == Release_Multi ) {
    274                 verify( !preemption_enabled );
     276                verify( !preemption.enabled );
    275277                for(int i = 0; i < lock_count; i++) {
    276278                        unlock( *locks[i] );
     
    304306        this_coroutine = NULL;
    305307        this_thread = NULL;
    306         preemption_enabled = false;
    307         disable_preempt_count = 1;
     308        preemption.enabled = false;
     309        preemption.disable_count = 1;
    308310        // SKULLDUGGERY: We want to create a context for the processor coroutine
    309311        // which is needed for the 2-step context switch. However, there is no reason
     
    345347}
    346348
     349void kernel_first_resume(processor * this) {
     350        coroutine_desc * src = this_coroutine;
     351        coroutine_desc * dst = get_coroutine(*this->runner);
     352
     353        verify( !preemption.enabled );
     354
     355        create_stack(&dst->stack, dst->stack.size);
     356        CtxStart(this->runner, CtxInvokeCoroutine);
     357
     358        verify( !preemption.enabled );
     359
     360        dst->last = src;
     361        dst->starter = dst->starter ? dst->starter : src;
     362
     363        // set state of current coroutine to inactive
     364        src->state = src->state == Halted ? Halted : Inactive;
     365
     366        // set new coroutine that task is executing
     367        this_coroutine = dst;
     368
     369        // SKULLDUGGERY normally interrupts are enable before leaving a coroutine ctxswitch.
     370        // Therefore, when first creating a coroutine, interrupts are enable before calling the main.
     371        // This is consistent with thread creation. However, when creating the main processor coroutine,
     372        // we wan't interrupts to be disabled. Therefore, we double-disable interrupts here so they will
     373        // stay disabled.
     374        disable_interrupts();
     375
     376        // context switch to specified coroutine
     377        assert( src->stack.context );
     378        CtxSwitch( src->stack.context, dst->stack.context );
     379        // when CtxSwitch returns we are back in the src coroutine
     380
     381        // set state of new coroutine to active
     382        src->state = Active;
     383
     384        verify( !preemption.enabled );
     385}
     386
    347387//-----------------------------------------------------------------------------
    348388// Scheduler routines
     
    352392        verify( thrd->self_cor.state != Halted );
    353393
    354         verify( !preemption_enabled );
     394        verify( !preemption.enabled );
    355395
    356396        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
     
    362402        }
    363403
    364         verify( !preemption_enabled );
     404        verify( !preemption.enabled );
    365405}
    366406
    367407thread_desc * nextThread(cluster * this) with( *this ) {
    368         verify( !preemption_enabled );
     408        verify( !preemption.enabled );
    369409        lock( ready_queue_lock __cfaabi_dbg_ctx2 );
    370410        thread_desc * head = pop_head( ready_queue );
    371411        unlock( ready_queue_lock );
    372         verify( !preemption_enabled );
     412        verify( !preemption.enabled );
    373413        return head;
    374414}
     
    376416void BlockInternal() {
    377417        disable_interrupts();
    378         verify( !preemption_enabled );
     418        verify( !preemption.enabled );
    379419        returnToKernel();
    380         verify( !preemption_enabled );
     420        verify( !preemption.enabled );
    381421        enable_interrupts( __cfaabi_dbg_ctx );
    382422}
     
    387427        this_processor->finish.lock        = lock;
    388428
    389         verify( !preemption_enabled );
     429        verify( !preemption.enabled );
    390430        returnToKernel();
    391         verify( !preemption_enabled );
     431        verify( !preemption.enabled );
    392432
    393433        enable_interrupts( __cfaabi_dbg_ctx );
     
    399439        this_processor->finish.thrd        = thrd;
    400440
    401         verify( !preemption_enabled );
     441        verify( !preemption.enabled );
    402442        returnToKernel();
    403         verify( !preemption_enabled );
     443        verify( !preemption.enabled );
    404444
    405445        enable_interrupts( __cfaabi_dbg_ctx );
     
    413453        this_processor->finish.thrd        = thrd;
    414454
    415         verify( !preemption_enabled );
     455        verify( !preemption.enabled );
    416456        returnToKernel();
    417         verify( !preemption_enabled );
     457        verify( !preemption.enabled );
    418458
    419459        enable_interrupts( __cfaabi_dbg_ctx );
     
    426466        this_processor->finish.lock_count  = count;
    427467
    428         verify( !preemption_enabled );
     468        verify( !preemption.enabled );
    429469        returnToKernel();
    430         verify( !preemption_enabled );
     470        verify( !preemption.enabled );
    431471
    432472        enable_interrupts( __cfaabi_dbg_ctx );
     
    441481        this_processor->finish.thrd_count  = thrd_count;
    442482
    443         verify( !preemption_enabled );
     483        verify( !preemption.enabled );
    444484        returnToKernel();
    445         verify( !preemption_enabled );
     485        verify( !preemption.enabled );
    446486
    447487        enable_interrupts( __cfaabi_dbg_ctx );
     
    449489
    450490void LeaveThread(__spinlock_t * lock, thread_desc * thrd) {
    451         verify( !preemption_enabled );
     491        verify( !preemption.enabled );
    452492        this_processor->finish.action_code = thrd ? Release_Schedule : Release;
    453493        this_processor->finish.lock        = lock;
     
    463503// Kernel boot procedures
    464504void kernel_startup(void) {
     505        verify( !preemption.enabled );
    465506        __cfaabi_dbg_print_safe("Kernel : Starting\n");
    466507
     
    500541        // context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that
    501542        // mainThread is on the ready queue when this call is made.
    502         resume( *mainProcessor->runner );
     543        kernel_first_resume( this_processor );
    503544
    504545
     
    507548        __cfaabi_dbg_print_safe("Kernel : Started\n--------------------------------------------------\n\n");
    508549
     550        verify( !preemption.enabled );
    509551        enable_interrupts( __cfaabi_dbg_ctx );
     552        verify( preemption.enabled );
    510553}
    511554
     
    513556        __cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n");
    514557
     558        verify( preemption.enabled );
    515559        disable_interrupts();
     560        verify( !preemption.enabled );
    516561
    517562        // SKULLDUGGERY: Notify the mainProcessor it needs to terminates.
  • src/libcfa/concurrency/kernel_private.h

    rc71b256 r7c782af  
    7474extern thread_local processor *      volatile this_processor;
    7575
    76 extern volatile thread_local bool preemption_in_progress;
    77 extern volatile thread_local bool preemption_enabled;
    78 extern volatile thread_local unsigned short disable_preempt_count;
     76// extern volatile thread_local bool preemption_in_progress;
     77// extern volatile thread_local bool preemption_enabled;
     78// extern volatile thread_local unsigned short disable_preempt_count;
     79
     80struct __cfa_kernel_preemption_data_t {
     81        bool enabled;
     82        bool in_progress;
     83        unsigned short disable_count;
     84};
     85
     86extern volatile thread_local __cfa_kernel_preemption_data_t preemption;
    7987
    8088//-----------------------------------------------------------------------------
  • src/libcfa/concurrency/monitor.c

    rc71b256 r7c782af  
    1010// Created On       : Thd Feb 23 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 16:12:20 2018
    13 // Update Count     : 4
     12// Last Modified On : Fri Feb 16 14:49:53 2018
     13// Update Count     : 5
    1414//
    1515
     
    427427                thread_desc * this_thrd = this_thread;
    428428                if ( this.monitor_count != this_thrd->monitors.size ) {
    429                         abort( "Signal on condition %p made with different number of monitor(s), expected %li got %li", &this, this.monitor_count, this_thrd->monitors.size );
     429                        abort( "Signal on condition %p made with different number of monitor(s), expected %zi got %zi", &this, this.monitor_count, this_thrd->monitors.size );
    430430                }
    431431
  • src/libcfa/concurrency/preemption.c

    rc71b256 r7c782af  
    149149        // Disable interrupts by incrementing the counter
    150150        void disable_interrupts() {
    151                 preemption_enabled = false;
    152                 __attribute__((unused)) unsigned short new_val = disable_preempt_count + 1;
    153                 disable_preempt_count = new_val;
     151                preemption.enabled = false;
     152                __attribute__((unused)) unsigned short new_val = preemption.disable_count + 1;
     153                preemption.disable_count = new_val;
    154154                verify( new_val < 65_000u );              // If this triggers someone is disabling interrupts without enabling them
    155155        }
     
    161161                thread_desc * thrd = this_thread;         // Cache the thread now since interrupts can start happening after the atomic add
    162162
    163                 unsigned short prev = disable_preempt_count;
    164                 disable_preempt_count -= 1;
     163                unsigned short prev = preemption.disable_count;
     164                preemption.disable_count -= 1;
    165165                verify( prev != 0u );                     // If this triggers someone is enabled already enabled interruptsverify( prev != 0u );
    166166
    167167                // Check if we need to prempt the thread because an interrupt was missed
    168168                if( prev == 1 ) {
    169                         preemption_enabled = true;
     169                        preemption.enabled = true;
    170170                        if( proc->pending_preemption ) {
    171171                                proc->pending_preemption = false;
     
    181181        // Don't execute any pending CtxSwitch even if counter reaches 0
    182182        void enable_interrupts_noPoll() {
    183                 unsigned short prev = disable_preempt_count;
    184                 disable_preempt_count -= 1;
     183                unsigned short prev = preemption.disable_count;
     184                preemption.disable_count -= 1;
    185185                verifyf( prev != 0u, "Incremented from %u\n", prev );                     // If this triggers someone is enabled already enabled interrupts
    186186                if( prev == 1 ) {
    187                         preemption_enabled = true;
     187                        preemption.enabled = true;
    188188                }
    189189        }
     
    235235// If false : preemption is unsafe and marked as pending
    236236static inline bool preemption_ready() {
    237         bool ready = preemption_enabled && !preemption_in_progress; // Check if preemption is safe
     237        bool ready = preemption.enabled && !preemption.in_progress; // Check if preemption is safe
    238238        this_processor->pending_preemption = !ready;                        // Adjust the pending flag accordingly
    239239        return ready;
     
    250250
    251251        // Start with preemption disabled until ready
    252         preemption_enabled = false;
    253         disable_preempt_count = 1;
     252        preemption.enabled = false;
     253        preemption.disable_count = 1;
    254254
    255255        // Initialize the event kernel
     
    290290// Used by thread to control when they want to receive preemption signals
    291291void ?{}( preemption_scope & this, processor * proc ) {
    292         (this.alarm){ proc, zero_time, zero_time };
     292        (this.alarm){ proc, 0`cfa_s, 0`cfa_s };
    293293        this.proc = proc;
    294294        this.proc->preemption_alarm = &this.alarm;
     
    300300        disable_interrupts();
    301301
    302         update_preemption( this.proc, zero_time );
     302        update_preemption( this.proc, 0`cfa_s );
    303303}
    304304
     
    330330        __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", this_processor, this_thread);
    331331
    332         preemption_in_progress = true;                      // Sync flag : prevent recursive calls to the signal handler
     332        preemption.in_progress = true;                      // Sync flag : prevent recursive calls to the signal handler
    333333        signal_unblock( SIGUSR1 );                          // We are about to CtxSwitch out of the signal handler, let other handlers in
    334         preemption_in_progress = false;                     // Clear the in progress flag
     334        preemption.in_progress = false;                     // Clear the in progress flag
    335335
    336336        // Preemption can occur here
  • src/libcfa/concurrency/thread.c

    rc71b256 r7c782af  
    9090}
    9191
     92extern "C" {
     93        void __finish_creation(void) {
     94                coroutine_desc* thrd_c = this_coroutine;
     95                ThreadCtxSwitch( thrd_c, thrd_c->last );
     96        }
     97}
     98
    9299void yield( void ) {
     100        verify( preemption.enabled );
    93101        BlockInternal( this_thread );
     102        verify( preemption.enabled );
    94103}
    95104
  • src/main.cc

    rc71b256 r7c782af  
    282282                } // if
    283283
     284                CodeTools::fillLocations( translationUnit );
     285
    284286                OPTPRINT( "resolve" )
    285287                ResolvExpr::resolve( translationUnit );
     
    361363                        cerr << endl << "---End of AST, begin error message:---\n" << endl;
    362364                } // if
    363                 e.print( cerr );
     365                e.print();
    364366                if ( output != &cout ) {
    365367                        delete output;
  • src/tests/.expect/alloc.txt

    rc71b256 r7c782af  
    22CFA malloc 0xdeadbeef
    33CFA alloc 0xdeadbeef
    4 CFA alloc, fill 01010101
     4CFA alloc, fill ffffffff
    55
    66C   array calloc, fill 0
     
    1010CFA array alloc, no fill
    11110xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    12 CFA array alloc, fill 0x1
    13 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
     12CFA array alloc, fill 0xff
     130xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
    1414
    1515C   realloc
     
    25250xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    2626CFA resize array alloc, fill
    27 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
     270xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
    2828CFA resize array alloc, fill
    29 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
     290xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
    3030CFA resize array alloc, fill
    31 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101
     310xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff
    3232
    3333C   memalign 42 42.5
     
    3737CFA aligned_alloc 42 42.5
    3838CFA align_alloc 42 42.5
    39 CFA align_alloc fill 0x1010101 0x1.1010101010101p-1007
     39CFA align_alloc fill 0xffffffff -nan
    4040
    4141CFA array align_alloc
    424242 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5, 42 42.5,
    4343CFA array align_alloc, fill
    44 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007,
     440xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan,
    4545
    46 CFA memset 0x1010101 0x1.1010101010101p-1007
    47 CFA memcpy 0x1010101 0x1.1010101010101p-1007
     46CFA memset 0xffffffff -nan
     47CFA memcpy 0xffffffff -nan
    4848
    4949CFA array memset
    50 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007,
     500xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan,
    5151CFA memcpy
    52 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007, 0x1010101 0x1.1010101010101p-1007,
     520xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan, 0xffffffff -nan,
    5353
    5454CFA new initialize
  • src/tests/alloc.c

    rc71b256 r7c782af  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan 22 21:26:40 2018
    13 // Update Count     : 326
     12// Last Modified On : Fri Feb 16 15:42:31 2018
     13// Update Count     : 330
    1414//
    1515
     
    2727int main( void ) {
    2828        size_t dim = 10;
     29        char fill = '\xff';
    2930        int * p;
    30         char fill = '\1';
    3131
    3232        // allocation, non-array types
     
    7979
    8080        p = alloc( 2 * dim, fill );                         // CFA array alloc, fill
    81         printf( "CFA array alloc, fill %#x\n", fill );
     81        printf( "CFA array alloc, fill %#hhx\n", fill );
    8282        for ( int i = 0; i < 2 * dim; i += 1 ) { printf( "%#x ", p[i] ); }
    8383        printf( "\n" );
  • src/tests/raii/.expect/dtor-early-exit-ERR2.txt

    rc71b256 r7c782af  
    1 raii/dtor-early-exit.c:220:1 error: jump to label 'L2' crosses initialization of y Branch (Goto)
     1raii/dtor-early-exit.c:217:1 error: jump to label 'L2' crosses initialization of y Branch (Goto)
    22  with target: L2
    33  with original target: L2
Note: See TracChangeset for help on using the changeset viewer.