xref: /aosp_15_r20/external/clang/test/CodeGenCXX/vtable-key-function.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2*67e74705SXin Li // PR5697
3*67e74705SXin Li namespace PR5697 {
4*67e74705SXin Li struct A {
fPR5697::A5*67e74705SXin Li   virtual void f() { }
6*67e74705SXin Li   A();
7*67e74705SXin Li   A(int);
8*67e74705SXin Li };
9*67e74705SXin Li 
10*67e74705SXin Li // A does not have a key function, so the first constructor we emit should
11*67e74705SXin Li // cause the vtable to be defined (without assertions.)
12*67e74705SXin Li // CHECK: @_ZTVN6PR56971AE = linkonce_odr unnamed_addr constant
A()13*67e74705SXin Li A::A() { }
A(int)14*67e74705SXin Li A::A(int) { }
15*67e74705SXin Li }
16*67e74705SXin Li 
17*67e74705SXin Li // Make sure that we don't assert when building the vtable for a class
18*67e74705SXin Li // template specialization or explicit instantiation with a key
19*67e74705SXin Li // function.
20*67e74705SXin Li template<typename T>
21*67e74705SXin Li struct Base {
22*67e74705SXin Li   virtual ~Base();
23*67e74705SXin Li };
24*67e74705SXin Li 
25*67e74705SXin Li template<typename T>
26*67e74705SXin Li struct Derived : public Base<T> { };
27*67e74705SXin Li 
28*67e74705SXin Li template<>
29*67e74705SXin Li struct Derived<char> : public Base<char> {
30*67e74705SXin Li   virtual void anchor();
31*67e74705SXin Li };
32*67e74705SXin Li 
anchor()33*67e74705SXin Li void Derived<char>::anchor() { }
34