diff options
| -rw-r--r-- | clang/lib/CodeGen/CGCXX.cpp | 4 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/ctor-dtor-alias.cpp | 15 |
2 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index f79e079745c..0f55616ea6b 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/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/clang/test/CodeGenCXX/ctor-dtor-alias.cpp b/clang/test/CodeGenCXX/ctor-dtor-alias.cpp index 745495ac68f..1ab66a04d0d 100644 --- a/clang/test/CodeGenCXX/ctor-dtor-alias.cpp +++ b/clang/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<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() {} +} |

