]> granicus.if.org Git - clang/commitdiff
Fix pr17875.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 11 Nov 2013 19:35:06 +0000 (19:35 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 11 Nov 2013 19:35:06 +0000 (19:35 +0000)
The assert this patch deletes was valid only when aliasing D2 to D1, not when
looking at a base class. Since the assert was in the path where we had already
decided to not produce an alias, just drop it.

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

lib/CodeGen/CGCXX.cpp
test/CodeGenCXX/ctor-dtor-alias.cpp

index f79e079745cd3ee15a445c5ae55d64a8b72d3935..0f55616ea6b14788ca3bd6bec390e036773faa32 100644 (file)
@@ -150,10 +150,8 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
     // Don't create an alias to a linker weak symbol unless we know we can do
     // that in every TU. This avoids producing different COMDATs in different
     // TUs.
-    if (llvm::GlobalValue::isWeakForLinker(TargetLinkage)) {
-      assert(Linkage == TargetLinkage);
+    if (llvm::GlobalValue::isWeakForLinker(TargetLinkage))
       return true;
-    }
   }
 
   // Create the alias with no name.
index 745495ac68ff9f6b1ac1d039af317d48bbcba70b..1ab66a04d0d60baed749b86f1b7a735de7c72418 100644 (file)
@@ -88,3 +88,18 @@ namespace test6 {
   B X;
   // CHECK-DAG: call i32 @__cxa_atexit({{.*}}@_ZN5test61AD2Ev
 }
+
+namespace test7 {
+  // Test that we don't produce an alias from ~B to ~A<int> (or crash figuring
+  // out if we should).
+  // pr17875.
+  // CHECK-DAG: define void @_ZN5test71BD2Ev
+  template <typename> struct A {
+    ~A() {}
+  };
+  class B : A<int> {
+    ~B();
+  };
+  template class A<int>;
+  B::~B() {}
+}