]> granicus.if.org Git - clang/commitdiff
Follow-up to r199120: don't try referencing the dtor if the param decl isn't valid.
authorHans Wennborg <hans@hanshq.net>
Mon, 13 Jan 2014 19:24:31 +0000 (19:24 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 13 Jan 2014 19:24:31 +0000 (19:24 +0000)
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

index 0e2b1f64d600a58a9f3516f60bb30b1b9d65e720..03363f7129b0bb3a5a409ea2045c9d24e1904a5d 100644 (file)
@@ -6246,14 +6246,16 @@ bool Sema::CheckParmsForFunctionDef(ParmVarDecl *const *P,
     if (getLangOpts().CPlusPlus && Context.getTargetInfo()
                                        .getCXXABI()
                                        .areArgsDestroyedLeftToRightInCallee()) {
-      if (const RecordType *RT = Param->getType()->getAs<RecordType>()) {
-        CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(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<RecordType>()) {
+          CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(RT->getDecl());
+          if (!ClassDecl->isInvalidDecl() &&
+              !ClassDecl->hasIrrelevantDestructor() &&
+              !ClassDecl->isDependentContext()) {
+            CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
+            MarkFunctionReferenced(Param->getLocation(), Destructor);
+            DiagnoseUseOfDecl(Destructor, Param->getLocation());
+          }
         }
       }
     }