Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    rb128d3e rbe9288a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 28 13:47:23 2017
    13 // Update Count     : 359
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tus Aug  8 13:27:00 2017
     13// Update Count     : 358
    1414//
    1515
     
    4747
    4848#include "CodeGen/CodeGenerator.h"     // for genName
    49 #include "CodeGen/OperatorTable.h"     // for isCtorDtor, isCtorDtorAssign
    5049#include "Common/PassVisitor.h"        // for PassVisitor, WithDeclsToAdd
    5150#include "Common/ScopedMap.h"          // for ScopedMap
     
    240239        };
    241240
    242 
    243         FunctionDecl * dereferenceOperator = nullptr;
    244         struct FindSpecialDeclarations final {
    245                 void previsit( FunctionDecl * funcDecl );
    246         };
    247 
    248241        void validate( std::list< Declaration * > &translationUnit, bool doDebug ) {
    249242                PassVisitor<EnumAndPointerDecay> epc;
     
    252245                PassVisitor<CompoundLiteral> compoundliteral;
    253246                PassVisitor<ValidateGenericParameters> genericParams;
    254                 PassVisitor<FindSpecialDeclarations> finder;
    255247
    256248                EliminateTypedef::eliminateTypedef( translationUnit );
     
    269261                acceptAll( translationUnit, fpd );
    270262                ArrayLength::computeLength( translationUnit );
    271                 acceptAll( translationUnit, finder );
    272263        }
    273264
     
    467458                        return;
    468459                }
    469 
    470                 // handle other traits
    471460                TraitDecl *traitDecl = indexer->lookupTrait( traitInst->get_name() );
    472461                if ( ! traitDecl ) {
     
    664653                } else {
    665654                        TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->get_name() );
    666                         assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst->get_name().c_str() );
     655                        assertf( base != typedeclNames.end(), "Can't find typedecl name %s", typeInst->get_name().c_str() );
    667656                        typeInst->set_baseType( base->second );
    668657                } // if
     
    832821                std::list< DeclarationWithType * > &params = funcType->get_parameters();
    833822
    834                 if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc.
     823                if ( InitTweak::isCtorDtorAssign( funcDecl->get_name() ) ) {
    835824                        if ( params.size() == 0 ) {
    836825                                throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl );
    837826                        }
    838                         ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() );
    839                         if ( ! refType ) {
    840                                 throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a reference ", funcDecl );
     827                        PointerType * ptrType = dynamic_cast< PointerType * >( params.front()->get_type() );
     828                        if ( ! ptrType || ptrType->is_array() ) {
     829                                throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a pointer ", funcDecl );
    841830                        }
    842                         if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {
     831                        if ( InitTweak::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {
    843832                                throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl );
    844833                        }
     
    956945                }
    957946        }
    958 
    959         void FindSpecialDeclarations::previsit( FunctionDecl * funcDecl ) {
    960                 if ( ! dereferenceOperator ) {
    961                         if ( funcDecl->get_name() == "*?" && funcDecl->get_linkage() == LinkageSpec::Intrinsic ) {
    962                                 FunctionType * ftype = funcDecl->get_functionType();
    963                                 if ( ftype->get_parameters().size() == 1 && ftype->get_parameters().front()->get_type()->get_qualifiers() == Type::Qualifiers() ) {
    964                                         dereferenceOperator = funcDecl;
    965                                 }
    966                         }
    967                 }
    968         }
    969947} // namespace SymTab
    970948
Note: See TracChangeset for help on using the changeset viewer.