Changeset 28e58fd for src/SymTab/Validate.cc
- Timestamp:
- Aug 25, 2017, 10:38:34 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 800d275
- Parents:
- af08051 (diff), 3eab308c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
raf08051 r28e58fd 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 … … 821 830 std::list< DeclarationWithType * > ¶ms = funcType->get_parameters(); 822 831 823 if ( InitTweak::isCtorDtorAssign( funcDecl->get_name() ) ) {832 if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc. 824 833 if ( params.size() == 0 ) { 825 834 throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl ); 826 835 } 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 );836 ReferenceType * refType = dynamic_cast< ReferenceType * >( params.front()->get_type() ); 837 if ( ! refType ) { 838 throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a reference ", funcDecl ); 830 839 } 831 if ( InitTweak::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) {840 if ( CodeGen::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) { 832 841 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl ); 833 842 } … … 945 954 } 946 955 } 956 957 void FindSpecialDeclarations::previsit( FunctionDecl * funcDecl ) { 958 if ( ! dereferenceOperator ) { 959 if ( funcDecl->get_name() == "*?" && funcDecl->get_linkage() == LinkageSpec::Intrinsic ) { 960 FunctionType * ftype = funcDecl->get_functionType(); 961 if ( ftype->get_parameters().size() == 1 && ftype->get_parameters().front()->get_type()->get_qualifiers() == Type::Qualifiers() ) { 962 dereferenceOperator = funcDecl; 963 } 964 } 965 } 966 } 947 967 } // namespace SymTab 948 968
Note:
See TracChangeset
for help on using the changeset viewer.