1// RUN: %clang_cc1 %s -fsyntax-only -verify -Wweak-vtables 2 3struct A { // expected-warning {{'A' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}} 4 virtual void f() { } 5}; 6 7template<typename T> struct B { 8 virtual void f() { } 9}; 10 11namespace { 12 struct C { 13 virtual void f() { } 14 }; 15} 16 17void f() { 18 struct A { 19 virtual void f() { } 20 }; 21 22 A *a; 23 a->f(); 24} 25 26// Use the vtables 27void uses(A &a, B<int> &b, C &c) { 28 a.f(); 29 b.f(); 30 c.f(); 31} 32 33// <rdar://problem/9979458> 34class Parent { 35public: 36 Parent() {} 37 virtual ~Parent(); 38 virtual void * getFoo() const = 0; 39}; 40 41class Derived : public Parent { 42public: 43 Derived(); 44 void * getFoo() const; 45}; 46 47class VeryDerived : public Derived { // expected-warning{{'VeryDerived' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}} 48public: 49 void * getFoo() const { return 0; } 50}; 51 52Parent::~Parent() {} 53 54void uses(Parent &p, Derived &d, VeryDerived &vd) { 55 p.getFoo(); 56 d.getFoo(); 57 vd.getFoo(); 58} 59