Changeset a2a8d2a6
- Timestamp:
- Aug 25, 2016, 2:03:29 PM (7 years ago)
- 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:
- 32a2a99
- Parents:
- 486341f
- git-author:
- Rob Schluntz <rschlunt@…> (08/25/16 11:09:18)
- git-committer:
- Rob Schluntz <rschlunt@…> (08/25/16 14:03:29)
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/SemanticError.cc
r486341f ra2a8d2a6 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // SemanticError.cc -- 7 // SemanticError.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 26 26 27 27 SemanticError::SemanticError( std::string error ) { 28 errors.push_back( std::string( "Error: " ) +error );28 append( error ); 29 29 } 30 30 31 31 void SemanticError::append( SemanticError &other ) { 32 errors.splice( errors.end(), other.errors ); 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 ); 33 37 } 34 38 -
src/Common/SemanticError.h
r486341f ra2a8d2a6 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // SemanticError.h -- 7 // SemanticError.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 31 31 32 32 void append( SemanticError &other ); 33 void append( const std::string & ); 33 34 bool isEmpty() const; 34 35 void print( std::ostream &os ); … … 42 43 template< typename T > 43 44 SemanticError::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 ) ); 48 46 } 47 49 48 50 49 #endif // SEMANTICERROR_H -
src/InitTweak/FixInit.cc
r486341f ra2a8d2a6 188 188 virtual void visit( ApplicationExpr * appExpr ); 189 189 190 SemanticError errors; 190 191 private: 191 192 void handleFirstParam( Expression * firstParam ); 193 template< typename... Params > 194 void emit( const Params &... params ); 192 195 193 196 FunctionDecl * function = 0; … … 258 261 WarnStructMembers warner; 259 262 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 } 260 268 } 261 269 } … … 735 743 for ( DeclarationWithType * member : unhandled ) { 736 744 // 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" ); 738 746 } 739 747 748 // need to steal the errors before they're lost 749 old.errors.append( errors ); 740 750 *this = old; 741 751 } … … 797 807 if ( unhandled.count( memberExpr->get_member() ) ) { 798 808 // 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" ); 800 810 } 801 811 } … … 805 815 Parent::visit( memberExpr ); 806 816 } 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 } 807 829 } // namespace 808 830 } // namespace InitTweak -
src/tests/.expect/ctorWarnings.txt
r486341f ra2a8d2a6 1 1 CFA 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 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 -
src/tests/Makefile.am
r486341f ra2a8d2a6 63 63 64 64 ctorWarnings: ctorWarnings.c 65 ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o /dev/null 2>${@}65 ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o ${@} 66 66 -
src/tests/Makefile.in
r486341f ra2a8d2a6 671 671 672 672 ctorWarnings: ctorWarnings.c 673 ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o /dev/null 2>${@}673 ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o ${@} 674 674 675 675 # Tell versions [3.59,3.63) of GNU make to not export all variables.
Note: See TracChangeset
for help on using the changeset viewer.