Changes in src/SymTab/Validate.cc [e491159:d1969a6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
re491159 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 }
Note: See TracChangeset
for help on using the changeset viewer.