]> granicus.if.org Git - clang/commitdiff
Merging r231451:
authorTom Stellard <thomas.stellard@amd.com>
Mon, 20 Apr 2015 15:17:50 +0000 (15:17 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Mon, 20 Apr 2015 15:17:50 +0000 (15:17 +0000)
------------------------------------------------------------------------
r231451 | nicolasweber | 2015-03-06 01:01:06 -0500 (Fri, 06 Mar 2015) | 5 lines

Don't crash on non-public referenced dtors in toplevel classes.

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/branches/release_36@235308 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 091fd27db85ddb838023f275c045b3264a3dafd0..8be11572b2e05cfcd31b2592c5a99e3a51e4c430 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,
@@ -11630,8 +11630,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())
       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>;
+}