brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · e520777 Raw
83 lines · cpp
1// RUN: %clang_cc1 %s -fsyntax-only -verify -triple %itanium_abi_triple -Wweak-vtables2//3// Check that this warning is disabled on MS ABI targets which don't have key4// functions.5// RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror -Wweak-vtables6//7// -Wweak-template-vtables is deprecated but we still parse it.8// RUN: %clang_cc1 %s -fsyntax-only -Werror -Wweak-template-vtables9 10struct A { // expected-warning {{'A' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}11  virtual void f() { } 12};13 14template<typename T> struct B {15  virtual void f() { } 16};17 18namespace {19  struct C { 20    virtual void f() { }21  };22}23 24void f() {25  struct A {26    virtual void f() { }27  };28 29  A a;30}31 32// Use the vtables33void uses_abc() {34  A a;35  B<int> b;36  C c;37}38 39class Parent {40public:41  Parent() {}42  virtual ~Parent();43  virtual void * getFoo() const = 0;    44};45  46class Derived : public Parent {47public:48  Derived();49  void * getFoo() const;50};51 52class VeryDerived : public Derived { // expected-warning{{'VeryDerived' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}53public:54  void * getFoo() const { return 0; }55};56 57Parent::~Parent() {}58 59void uses_derived() {60  Derived d;61  VeryDerived vd;62}63 64template<typename T> struct TemplVirt {65  virtual void f();66};67 68template class TemplVirt<float>;69 70template<> struct TemplVirt<bool> {71  virtual void f();72};73 74template<> struct TemplVirt<long> { // expected-warning{{'TemplVirt<long>' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}75  virtual void f() {}76};77 78void uses_templ() {79  TemplVirt<float> f;80  TemplVirt<bool> b;81  TemplVirt<long> l;82}83