summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-03-06 06:01:06 +0000
committerNico Weber <nicolasweber@gmx.de>2015-03-06 06:01:06 +0000
commit55905145e7cfe2adca541e7162b91d23a4e7f26c (patch)
tree4ea746cde850d89e53d033c5860962b13baa543d
parent72146af68c9cfa570d32f52f961e1b15f91d8a2b (diff)
downloadbcm5719-llvm-55905145e7cfe2adca541e7162b91d23a4e7f26c.tar.gz
bcm5719-llvm-55905145e7cfe2adca541e7162b91d23a4e7f26c.zip
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. llvm-svn: 231451
-rw-r--r--clang/lib/Sema/SemaExpr.cpp7
-rw-r--r--clang/test/CodeGenCXX/trivial-constructor-init.cpp14
2 files changed, 19 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3725b2d1f3c..84315be781f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -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)) {
diff --git a/clang/test/CodeGenCXX/trivial-constructor-init.cpp b/clang/test/CodeGenCXX/trivial-constructor-init.cpp
index 9130e4e5d95..da17799dfa4 100644
--- a/clang/test/CodeGenCXX/trivial-constructor-init.cpp
+++ b/clang/test/CodeGenCXX/trivial-constructor-init.cpp
@@ -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>;
+}
OpenPOWER on IntegriCloud