From: Rafael Espindola Date: Mon, 11 Nov 2013 19:35:06 +0000 (+0000) Subject: Fix pr17875. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47a2ab904faf4bbf3a97fc7172c549db1c1f3090;p=clang Fix pr17875. 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 --- diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index f79e079745..0f55616ea6 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -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. diff --git a/test/CodeGenCXX/ctor-dtor-alias.cpp b/test/CodeGenCXX/ctor-dtor-alias.cpp index 745495ac68..1ab66a04d0 100644 --- a/test/CodeGenCXX/ctor-dtor-alias.cpp +++ b/test/CodeGenCXX/ctor-dtor-alias.cpp @@ -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 (or crash figuring + // out if we should). + // pr17875. + // CHECK-DAG: define void @_ZN5test71BD2Ev + template struct A { + ~A() {} + }; + class B : A { + ~B(); + }; + template class A; + B::~B() {} +}