diff options
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 36cb656966..989e08ee9d 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2456,6 +2456,16 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl, CheckConstructor(Constructor); } else if (isa<CXXDestructorDecl>(NewFD)) { CXXRecordDecl *Record = cast<CXXRecordDecl>(NewFD->getParent()); + QualType ClassType = Context.getTypeDeclType(Record); + if (!ClassType->isDependentType()) { + ClassType = Context.getCanonicalType(ClassType); + DeclarationName Name + = Context.DeclarationNames.getCXXDestructorName(ClassType); + if (NewFD->getDeclName() != Name) { + Diag(NewFD->getLocation(), diag::err_destructor_name); + return NewFD->setInvalidDecl(); + } + } Record->setUserDeclaredDestructor(true); // C++ [class]p4: A POD-struct is an aggregate class that has [...] no // user-defined destructor. |