]> granicus.if.org Git - clang/commitdiff
Don't crash on non-public referenced dtors in toplevel classes.
authorNico Weber <nicolasweber@gmx.de>
Fri, 6 Mar 2015 06:01:06 +0000 (06:01 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 6 Mar 2015 06:01:06 +0000 (06:01 +0000)
Fixes PR22793, a bug that caused self-hosting to fail after the innocuous
r231254. See the bug for details.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231451 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CodeGenCXX/trivial-constructor-init.cpp

index 3725b2d1f3c4d7d30336adfb5ad8938a5cf8727a..84315be781f83cd7402d572c42cd347de7f88525 100644 (file)
@@ -117,7 +117,7 @@ static AvailabilityResult DiagnoseAvailabilityOfDecl(Sema &S,
     case AR_Available:
     case AR_NotYetIntroduced:
       break;
-            
+
     case AR_Deprecated:
       if (S.getCurContextAvailability() != AR_Deprecated)
         S.EmitAvailabilityWarning(Sema::AD_Deprecation,
@@ -11859,8 +11859,11 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
   } else if (CXXDestructorDecl *Destructor =
                  dyn_cast<CXXDestructorDecl>(Func)) {
     Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
-    if (Destructor->isDefaulted() && !Destructor->isDeleted())
+    if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
+      if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
+        return;
       DefineImplicitDestructor(Loc, Destructor);
+    }
     if (Destructor->isVirtual() && getLangOpts().AppleKext)
       MarkVTableUsed(Loc, Destructor->getParent());
   } else if (CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
index 9130e4e5d959e084bb09436b7352f0e18d2df152..da17799dfa4254e7c8490e50dd9f4cc670e5eaed 100644 (file)
@@ -32,3 +32,17 @@ static C c[4];
 
 int main() {
 }
+
+namespace PR22793 {
+template <typename>
+struct foo {
+protected:
+// CHECK-NOT: _ZN7PR227933fooIiED2Ev
+  ~foo() = default;
+  friend void func();
+};
+
+void func() { foo<int> f; }
+
+template struct foo<int>;
+}