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