Changes in / [90e2334:bda58ad]


Ignore:
Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.cc

    r90e2334 rbda58ad  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // SemanticError.cc --
     7// SemanticError.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    2626
    2727SemanticError::SemanticError( std::string error ) {
    28   append( error );
     28        errors.push_back( std::string( "Error: " ) + error );
    2929}
    3030
    3131void SemanticError::append( SemanticError &other ) {
    32   errors.splice( errors.end(), other.errors );
    33 }
    34 
    35 void SemanticError::append( const std::string & msg ) {
    36   errors.push_back( std::string( "Error: ") + msg );
     32        errors.splice( errors.end(), other.errors );
    3733}
    3834
  • src/Common/SemanticError.h

    r90e2334 rbda58ad  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // SemanticError.h --
     7// SemanticError.h -- 
    88//
    99// Author           : Richard C. Bilson
     
    3131
    3232        void append( SemanticError &other );
    33         void append( const std::string & );
    3433        bool isEmpty() const;
    3534        void print( std::ostream &os );
     
    4342template< typename T >
    4443SemanticError::SemanticError( const std::string &error, const T *obj ) {
    45         append( toString( error, obj ) );
     44        std::ostringstream os;
     45        os << "Error: " << error;
     46        obj->print( os );
     47        errors.push_back( os.str() );
    4648}
    47 
    4849
    4950#endif // SEMANTICERROR_H
  • src/InitTweak/FixInit.cc

    r90e2334 rbda58ad  
    188188                        virtual void visit( ApplicationExpr * appExpr );
    189189
    190                         SemanticError errors;
    191190                  private:
    192191                        void handleFirstParam( Expression * firstParam );
    193                         template< typename... Params >
    194                         void emit( const Params &... params );
    195192
    196193                        FunctionDecl * function = 0;
     
    261258                                WarnStructMembers warner;
    262259                                acceptAll( translationUnit, warner );
    263 
    264                                 // visitor doesn't throw so that it can collect all errors
    265                                 if ( ! warner.errors.isEmpty() ) {
    266                                         throw warner.errors;
    267                                 }
    268260                        }
    269261                }
     
    743735                        for ( DeclarationWithType * member : unhandled ) {
    744736                                // emit a warning for each unhandled member
    745                                 emit( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", member->get_name(), " may not have been ", isConstructor( funcDecl->get_name() ) ? "constructed" : "destructed" );
     737                                warn( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", member->get_name(), " may not have been ", isConstructor( funcDecl->get_name() ) ? "constructed" : "destructed" );
    746738                        }
    747739
    748                         // need to steal the errors before they're lost
    749                         old.errors.append( errors );
    750740                        *this = old;
    751741                }
     
    807797                                                        if ( unhandled.count( memberExpr->get_member() ) ) {
    808798                                                                // emit a warning because a member was used before it was constructed
    809                                                                 emit( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", memberExpr->get_member()->get_name(), " used before being constructed" );
     799                                                                warn( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", memberExpr->get_member()->get_name(), " used before being constructed" );
    810800                                                        }
    811801                                                }
     
    815805                        Parent::visit( memberExpr );
    816806                }
    817 
    818                 template< typename Visitor, typename... Params >
    819                 void error( Visitor & v, const Params &... params ) {
    820                         v.errors.append( toString( params... ) );
    821                 }
    822 
    823                 template< typename... Params >
    824                 void WarnStructMembers::emit( const Params &... params ) {
    825                         // toggle warnings vs. errors here.
    826                         // warn( params... );
    827                         error( *this, params... );
    828                 }
    829807        } // namespace
    830808} // namespace InitTweak
  • src/tests/.expect/ctorWarnings.txt

    r90e2334 rbda58ad  
    11CFA Version 1.0.0 (debug)
    2 Error: in void ?{}(struct A *a, int x), member z may not have been constructed
    3 Error: in void ?{}(struct B *b), member a2 used before being constructed
    4 Error: in void ?{}(struct B *b), member a2 may not have been constructed
    5 Error: in void ?{}(struct B *b), member a3 may not have been constructed
    6 Error: in void ^?{}(struct B *b), member a2 may not have been destructed
    7 Error: in void ^?{}(struct B *b), member a3 may not have been destructed
    8 make: *** [ctorWarnings] Error 1
     2Warning: in void ?{}(struct A *a, int x), member z may not have been constructed
     3Warning: in void ?{}(struct B *b), member a2 used before being constructed
     4Warning: in void ?{}(struct B *b), member a2 may not have been constructed
     5Warning: in void ?{}(struct B *b), member a3 may not have been constructed
     6Warning: in void ^?{}(struct B *b), member a2 may not have been destructed
     7Warning: in void ^?{}(struct B *b), member a3 may not have been destructed
  • src/tests/Makefile.am

    r90e2334 rbda58ad  
    6363
    6464ctorWarnings: ctorWarnings.c
    65         ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o ${@}
     65        ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o /dev/null 2> ${@}
    6666
  • src/tests/Makefile.in

    r90e2334 rbda58ad  
    671671
    672672ctorWarnings: ctorWarnings.c
    673         ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o ${@}
     673        ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o /dev/null 2> ${@}
    674674
    675675# Tell versions [3.59,3.63) of GNU make to not export all variables.
Note: See TracChangeset for help on using the changeset viewer.