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