Changes in src/SymTab/Validate.cc [d1969a6:e491159]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
rd1969a6 re491159 60 60 #include "ResolvExpr/typeops.h" 61 61 #include <algorithm> 62 #include "InitTweak/InitTweak.h"63 62 64 63 #define debugPrint( x ) if ( doDebug ) { std::cout << x; } … … 172 171 }; 173 172 174 class VerifyCtorDtor Assign: public Visitor {173 class VerifyCtorDtor : public Visitor { 175 174 public: 176 /// ensure that constructors , destructors, and assignmenthave at least one177 /// parameter, the first of which must be a pointer, and that ctor/dtors haveno175 /// ensure that constructors and destructors have at least one 176 /// parameter, the first of which must be a pointer, and no 178 177 /// return values. 179 178 static void verify( std::list< Declaration * > &translationUnit ); … … 203 202 compoundliteral.mutateDeclarationList( translationUnit ); 204 203 acceptAll( translationUnit, pass3 ); 205 VerifyCtorDtor Assign::verify( translationUnit );204 VerifyCtorDtor::verify( translationUnit ); 206 205 } 207 206 … … 688 687 } 689 688 690 void VerifyCtorDtor Assign::verify( std::list< Declaration * > & translationUnit ) {691 VerifyCtorDtor Assignverifier;689 void VerifyCtorDtor::verify( std::list< Declaration * > & translationUnit ) { 690 VerifyCtorDtor verifier; 692 691 acceptAll( translationUnit, verifier ); 693 692 } 694 693 695 void VerifyCtorDtor Assign::visit( FunctionDecl * funcDecl ) {694 void VerifyCtorDtor::visit( FunctionDecl * funcDecl ) { 696 695 FunctionType * funcType = funcDecl->get_functionType(); 697 696 std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals(); 698 697 std::list< DeclarationWithType * > ¶ms = funcType->get_parameters(); 699 698 700 if ( InitTweak::isCtorDtorAssign( funcDecl->get_name() )) {699 if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}" ) { 701 700 if ( params.size() == 0 ) { 702 throw SemanticError( "Constructors , destructors, and assignment functions require at least one parameter ", funcDecl );701 throw SemanticError( "Constructors and destructors require at least one parameter ", funcDecl ); 703 702 } 704 703 if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) { 705 throw SemanticError( "First parameter of a constructor , destructor, or assignment functionmust be a pointer ", funcDecl );704 throw SemanticError( "First parameter of a constructor or destructor must be a pointer ", funcDecl ); 706 705 } 707 if ( InitTweak::isCtorDtor( funcDecl->get_name() ) &&returnVals.size() != 0 ) {706 if ( returnVals.size() != 0 ) { 708 707 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl ); 709 708 }
Note:
See TracChangeset
for help on using the changeset viewer.