aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2011-02-06 20:09:44 +0000
committerAnders Carlsson <andersca@mac.com>2011-02-06 20:09:44 +0000
commit22df7b17f1b086f4347256406703d259753a0cbf (patch)
treef8eca9a9ec35c95a6f23e6254aac304d9b1304dd
parent14e82fd91c6d5041aa840574143521d244f185cd (diff)
Fix self-host; if a thunk already exists and has available_externally linkage, we should change its linkage instead of asserting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124986 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGVTables.cpp9
-rw-r--r--test/CodeGenCXX/thunks-available-externally.cpp18
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp
index 3dd7a15fe3..d74226ec89 100644
--- a/lib/CodeGen/CGVTables.cpp
+++ b/lib/CodeGen/CGVTables.cpp
@@ -2723,8 +2723,13 @@ void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
return;
}
- // We should never be able to get a function with a definition here.
- assert(false && "Shouldn't have an already existing definition");
+ // If a function has a body, it should have available_externally linkage.
+ assert(ThunkFn->hasAvailableExternallyLinkage() &&
+ "Function should have available_externally linkage!");
+
+ // Change the linkage.
+ CGM.setFunctionLinkage(cast<CXXMethodDecl>(GD.getDecl()), ThunkFn);
+ return;
}
// Actually generate the thunk body.
diff --git a/test/CodeGenCXX/thunks-available-externally.cpp b/test/CodeGenCXX/thunks-available-externally.cpp
index 697a000187..dfdb786b18 100644
--- a/test/CodeGenCXX/thunks-available-externally.cpp
+++ b/test/CodeGenCXX/thunks-available-externally.cpp
@@ -68,3 +68,21 @@ void f() {
}
}
+
+// Test that we don't assert.
+namespace Test3 {
+
+struct A {
+ virtual ~A();
+
+ int a;
+};
+
+struct B : A { };
+struct C : virtual B { };
+
+void f() {
+ C c;
+}
+
+}