Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    rd1969a6 re491159  
    6060#include "ResolvExpr/typeops.h"
    6161#include <algorithm>
    62 #include "InitTweak/InitTweak.h"
    6362
    6463#define debugPrint( x ) if ( doDebug ) { std::cout << x; }
     
    172171        };
    173172
    174         class VerifyCtorDtorAssign : public Visitor {
     173        class VerifyCtorDtor : public Visitor {
    175174        public:
    176                 /// 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
     175                /// ensure that constructors and destructors have at least one
     176                /// parameter, the first of which must be a pointer, and no
    178177                /// return values.
    179178                static void verify( std::list< Declaration * > &translationUnit );
     
    203202                compoundliteral.mutateDeclarationList( translationUnit );
    204203                acceptAll( translationUnit, pass3 );
    205                 VerifyCtorDtorAssign::verify( translationUnit );
     204                VerifyCtorDtor::verify( translationUnit );
    206205        }
    207206
     
    688687        }
    689688
    690         void VerifyCtorDtorAssign::verify( std::list< Declaration * > & translationUnit ) {
    691                 VerifyCtorDtorAssign verifier;
     689        void VerifyCtorDtor::verify( std::list< Declaration * > & translationUnit ) {
     690                VerifyCtorDtor verifier;
    692691                acceptAll( translationUnit, verifier );
    693692        }
    694693
    695         void VerifyCtorDtorAssign::visit( FunctionDecl * funcDecl ) {
     694        void VerifyCtorDtor::visit( FunctionDecl * funcDecl ) {
    696695                FunctionType * funcType = funcDecl->get_functionType();
    697696                std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals();
    698697                std::list< DeclarationWithType * > &params = funcType->get_parameters();
    699698
    700                 if ( InitTweak::isCtorDtorAssign( funcDecl->get_name() ) ) {
     699                if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}" ) {
    701700                        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 );
    703702                        }
    704703                        if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) {
    705                                 throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a pointer ", funcDecl );
     704                                throw SemanticError( "First parameter of a constructor or destructor must be a pointer ", funcDecl );
    706705                        }
    707                         if ( InitTweak::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {
     706                        if ( returnVals.size() != 0 ) {
    708707                                throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl );
    709708                        }
Note: See TracChangeset for help on using the changeset viewer.