Changeset d1969a6
- Timestamp:
- Sep 9, 2016, 9:20:33 AM (8 years ago)
- 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:
- b6fe7e6
- Parents:
- 4563a95
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/InitTweak.cc
r4563a95 rd1969a6 358 358 template<typename CallExpr> 359 359 Expression *& callArg( CallExpr * callExpr, unsigned int pos ) { 360 if ( pos >= callExpr->get_args().size() ) assert ( false &&"asking for argument that doesn't exist. Return NULL/throw exception?" );360 if ( pos >= callExpr->get_args().size() ) assertf( false, "asking for argument that doesn't exist. Return NULL/throw exception?" ); 361 361 for ( Expression *& arg : callExpr->get_args() ) { 362 362 if ( pos == 0 ) return arg; … … 373 373 return callArg( untypedExpr, pos ); 374 374 } else { 375 assert ( false &&"Unexpected expression type passed to getCallArg" );375 assertf( false, "Unexpected expression type passed to getCallArg" ); 376 376 } 377 377 } … … 388 388 return memberExpr->get_member()->get_name(); 389 389 } else { 390 assert ( false &&"Unexpected expression type being called as a function in call expression" );390 assertf( false, "Unexpected expression type being called as a function in call expression" ); 391 391 } 392 392 } … … 400 400 } else { 401 401 std::cerr << expr << std::endl; 402 assert ( false &&"Unexpected expression type passed to getFunctionName" );402 assertf( false, "Unexpected expression type passed to getFunctionName" ); 403 403 } 404 404 } -
src/SymTab/Validate.cc
r4563a95 rd1969a6 60 60 #include "ResolvExpr/typeops.h" 61 61 #include <algorithm> 62 #include "InitTweak/InitTweak.h" 62 63 63 64 #define debugPrint( x ) if ( doDebug ) { std::cout << x; } … … 171 172 }; 172 173 173 class VerifyCtorDtor : public Visitor {174 class VerifyCtorDtorAssign : public Visitor { 174 175 public: 175 /// ensure that constructors and destructorshave at least one176 /// parameter, the first of which must be a pointer, and no176 /// ensure that constructors, destructors, and assignment have at least one 177 /// parameter, the first of which must be a pointer, and that ctor/dtors have no 177 178 /// return values. 178 179 static void verify( std::list< Declaration * > &translationUnit ); … … 202 203 compoundliteral.mutateDeclarationList( translationUnit ); 203 204 acceptAll( translationUnit, pass3 ); 204 VerifyCtorDtor ::verify( translationUnit );205 VerifyCtorDtorAssign::verify( translationUnit ); 205 206 } 206 207 … … 687 688 } 688 689 689 void VerifyCtorDtor ::verify( std::list< Declaration * > & translationUnit ) {690 VerifyCtorDtor verifier;690 void VerifyCtorDtorAssign::verify( std::list< Declaration * > & translationUnit ) { 691 VerifyCtorDtorAssign verifier; 691 692 acceptAll( translationUnit, verifier ); 692 693 } 693 694 694 void VerifyCtorDtor ::visit( FunctionDecl * funcDecl ) {695 void VerifyCtorDtorAssign::visit( FunctionDecl * funcDecl ) { 695 696 FunctionType * funcType = funcDecl->get_functionType(); 696 697 std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals(); 697 698 std::list< DeclarationWithType * > ¶ms = funcType->get_parameters(); 698 699 699 if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}") {700 if ( InitTweak::isCtorDtorAssign( funcDecl->get_name() ) ) { 700 701 if ( params.size() == 0 ) { 701 throw SemanticError( "Constructors and destructors require at least one parameter ", funcDecl );702 throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl ); 702 703 } 703 704 if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) { 704 throw SemanticError( "First parameter of a constructor or destructormust be a pointer ", funcDecl );705 throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a pointer ", funcDecl ); 705 706 } 706 if ( returnVals.size() != 0 ) {707 if ( InitTweak::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) { 707 708 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl ); 708 709 } -
src/include/assert.h
r4563a95 rd1969a6 22 22 #define assertf(expr, fmt, ...) ((expr) ? static_cast<void>(0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ )) 23 23 24 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) ;24 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) __attribute__((noreturn)); 25 25 26 26 template<typename T, typename U>
Note: See TracChangeset
for help on using the changeset viewer.