Changeset 3906301


Ignore:
Timestamp:
Aug 29, 2016, 5:58:17 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, 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:
fa463f1
Parents:
486341f
git-author:
Rob Schluntz <rschlunt@…> (08/25/16 11:09:18)
git-committer:
Rob Schluntz <rschlunt@…> (08/29/16 17:58:17)
Message:

change constructor warnings into errors and update the test output

Location:
src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.cc

    r486341f r3906301  
    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         errors.push_back( std::string( "Error: " ) + error );
     28  append( error );
    2929}
    3030
    3131void SemanticError::append( SemanticError &other ) {
    32         errors.splice( errors.end(), other.errors );
     32  errors.splice( errors.end(), other.errors );
     33}
     34
     35void SemanticError::append( const std::string & msg ) {
     36  errors.push_back( std::string( "Error: ") + msg );
    3337}
    3438
  • src/Common/SemanticError.h

    r486341f r3906301  
    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 & );
    3334        bool isEmpty() const;
    3435        void print( std::ostream &os );
     
    4243template< typename T >
    4344SemanticError::SemanticError( const std::string &error, const T *obj ) {
    44         std::ostringstream os;
    45         os << "Error: " << error;
    46         obj->print( os );
    47         errors.push_back( os.str() );
     45        append( toString( error, obj ) );
    4846}
     47
    4948
    5049#endif // SEMANTICERROR_H
  • src/InitTweak/FixInit.cc

    r486341f r3906301  
    188188                        virtual void visit( ApplicationExpr * appExpr );
    189189
     190                        SemanticError errors;
    190191                  private:
    191192                        void handleFirstParam( Expression * firstParam );
     193                        template< typename... Params >
     194                        void emit( const Params &... params );
    192195
    193196                        FunctionDecl * function = 0;
     
    258261                                WarnStructMembers warner;
    259262                                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                                }
    260268                        }
    261269                }
     
    735743                        for ( DeclarationWithType * member : unhandled ) {
    736744                                // emit a warning for each unhandled member
    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" );
     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" );
    738746                        }
    739747
     748                        // need to steal the errors before they're lost
     749                        old.errors.append( errors );
    740750                        *this = old;
    741751                }
     
    797807                                                        if ( unhandled.count( memberExpr->get_member() ) ) {
    798808                                                                // emit a warning because a member was used before it was constructed
    799                                                                 warn( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", memberExpr->get_member()->get_name(), " used before being constructed" );
     809                                                                emit( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", memberExpr->get_member()->get_name(), " used before being constructed" );
    800810                                                        }
    801811                                                }
     
    805815                        Parent::visit( memberExpr );
    806816                }
     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                }
    807829        } // namespace
    808830} // namespace InitTweak
  • src/SynTree/Declaration.cc

    r486341f r3906301  
    5656}
    5757
    58 std::ostream & operator<<( std::ostream & out, Declaration * decl ) {
     58std::ostream & operator<<( std::ostream & out, const Declaration * decl ) {
    5959        decl->print( out );
    6060        return out;
  • src/SynTree/Declaration.h

    r486341f r3906301  
    279279};
    280280
    281 std::ostream & operator<<( std::ostream & out, Declaration * decl );
     281std::ostream & operator<<( std::ostream & out, const Declaration * decl );
    282282
    283283#endif // DECLARATION_H
  • src/SynTree/Expression.cc

    r486341f r3906301  
    541541}
    542542
    543 std::ostream & operator<<( std::ostream & out, Expression * expr ) {
     543std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
    544544        expr->print( out );
    545545        return out;
  • src/SynTree/Expression.h

    r486341f r3906301  
    653653};
    654654
    655 std::ostream & operator<<( std::ostream & out, Expression * expr );
     655std::ostream & operator<<( std::ostream & out, const Expression * expr );
    656656
    657657#endif // EXPRESSION_H
  • src/SynTree/Statement.cc

    r486341f r3906301  
    387387}
    388388
    389 std::ostream & operator<<( std::ostream & out, Statement * statement ) {
     389std::ostream & operator<<( std::ostream & out, const Statement * statement ) {
    390390        statement->print( out );
    391391        return out;
  • src/SynTree/Statement.h

    r486341f r3906301  
    395395
    396396
    397 std::ostream & operator<<( std::ostream & out, Statement * statement );
     397std::ostream & operator<<( std::ostream & out, const Statement * statement );
    398398
    399399#endif // STATEMENT_H
  • src/SynTree/Type.cc

    r486341f r3906301  
    8484}
    8585
    86 std::ostream & operator<<( std::ostream & out, Type * type ) {
     86std::ostream & operator<<( std::ostream & out, const Type * type ) {
    8787        type->print( out );
    8888        return out;
  • src/SynTree/Type.h

    r486341f r3906301  
    480480}
    481481
    482 std::ostream & operator<<( std::ostream & out, Type * type );
     482std::ostream & operator<<( std::ostream & out, const Type * type );
    483483
    484484#endif // TYPE_H
  • src/tests/.expect/ctorWarnings.txt

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

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

    r486341f r3906301  
    671671
    672672ctorWarnings: ctorWarnings.c
    673         ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o /dev/null 2> ${@}
     673        ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o ${@}
    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.