From 324f835127f652705aa6c6a80ed45fdbb3e81054 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Mon, 13 Jan 2014 19:24:31 +0000 Subject: [PATCH] Follow-up to r199120: don't try referencing the dtor if the param decl isn't valid. This was caught by running test/SemaCXX/destructor.cpp in MS ABI mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199128 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaChecking.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 0e2b1f64d6..03363f7129 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -6246,14 +6246,16 @@ bool Sema::CheckParmsForFunctionDef(ParmVarDecl *const *P, if (getLangOpts().CPlusPlus && Context.getTargetInfo() .getCXXABI() .areArgsDestroyedLeftToRightInCallee()) { - if (const RecordType *RT = Param->getType()->getAs()) { - CXXRecordDecl *ClassDecl = cast(RT->getDecl()); - if (!ClassDecl->isInvalidDecl() && - !ClassDecl->hasIrrelevantDestructor() && - !ClassDecl->isDependentContext()) { - CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl); - MarkFunctionReferenced(Param->getLocation(), Destructor); - DiagnoseUseOfDecl(Destructor, Param->getLocation()); + if (!Param->isInvalidDecl()) { + if (const RecordType *RT = Param->getType()->getAs()) { + CXXRecordDecl *ClassDecl = cast(RT->getDecl()); + if (!ClassDecl->isInvalidDecl() && + !ClassDecl->hasIrrelevantDestructor() && + !ClassDecl->isDependentContext()) { + CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl); + MarkFunctionReferenced(Param->getLocation(), Destructor); + DiagnoseUseOfDecl(Destructor, Param->getLocation()); + } } } } -- 2.40.0