Changes in src/SymTab/Validate.cc [be9288a:b128d3e]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
rbe9288a rb128d3e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tus Aug 8 13:27:00201713 // Update Count : 35 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 28 13:47:23 2017 13 // Update Count : 359 14 14 // 15 15 … … 47 47 48 48 #include "CodeGen/CodeGenerator.h" // for genName 49 #include "CodeGen/OperatorTable.h" // for isCtorDtor, isCtorDtorAssign 49 50 #include "Common/PassVisitor.h" // for PassVisitor, WithDeclsToAdd 50 51 #include "Common/ScopedMap.h" // for ScopedMap … … 239 240 }; 240 241 242 243 FunctionDecl * dereferenceOperator = nullptr; 244 struct FindSpecialDeclarations final { 245 void previsit( FunctionDecl * funcDecl ); 246 }; 247 241 248 void validate( std::list< Declaration * > &translationUnit, bool doDebug ) { 242 249 PassVisitor<EnumAndPointerDecay> epc; … … 245 252 PassVisitor<CompoundLiteral> compoundliteral; 246 253 PassVisitor<ValidateGenericParameters> genericParams; 254 PassVisitor<FindSpecialDeclarations> finder; 247 255 248 256 EliminateTypedef::eliminateTypedef( translationUnit ); … … 261 269 acceptAll( translationUnit, fpd ); 262 270 ArrayLength::computeLength( translationUnit ); 271 acceptAll( translationUnit, finder ); 263 272 } 264 273 … … 458 467 return; 459 468 } 469 470 // handle other traits 460 471 TraitDecl *traitDecl = indexer->lookupTrait( traitInst->get_name() ); 461 472 if ( ! traitDecl ) { … … 653 664 } else { 654 665 TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->get_name() ); 655 assertf( base != typedeclNames.end(), "Can 't find typedecl name %s", typeInst->get_name().c_str() );666 assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst->get_name().c_str() ); 656 667 typeInst->set_baseType( base->second ); 657 668 } // if … … 821 832 std::list< DeclarationWithType * > ¶ms = funcType->get_parameters(); 822 833 823 if ( InitTweak::isCtorDtorAssign( funcDecl->get_name() ) ) {834 if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc. 824 835 if ( params.size() == 0 ) { 825 836 throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl ); 826 837 } 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 );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 ); 830 841 } 831 if ( InitTweak::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {842 if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) { 832 843 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl ); 833 844 } … … 945 956 } 946 957 } 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 } 947 969 } // namespace SymTab 948 970
Note:
See TracChangeset
for help on using the changeset viewer.