brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · f6f52d5 Raw
74 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++11 %s2 3class A {4  virtual void f();5  virtual void g() = 0; // expected-note{{unimplemented pure virtual method 'g' in 'A'}}6 7  void h() = 0; // expected-error {{'h' is not virtual and cannot be declared pure}}8  void i() = 1; // expected-error {{initializer on function does not look like a pure-specifier}}9  void j() = 0u; // expected-error {{initializer on function does not look like a pure-specifier}}10 11 12  void k();13 14public:15  A(int);16};17 18virtual void A::k() { } // expected-error{{'virtual' can only be specified inside the class definition}}19 20class B : public A {21  // Needs to recognize that overridden function is virtual.22  void g() = 0;23 24  // Needs to recognize that function does not override.25  void g(int) = 0; // expected-error{{'g' is not virtual and cannot be declared pure}}26};27 28// Needs to recognize invalid uses of abstract classes.29A fn(A) // expected-error{{parameter type 'A' is an abstract class}} \30        // expected-error{{return type 'A' is an abstract class}}31{32  A a; // expected-error{{variable type 'A' is an abstract class}}33  (void)static_cast<A>(0); // expected-error{{allocating an object of abstract class type 'A'}}34  try {35  } catch(A) { // expected-error{{variable type 'A' is an abstract class}}36  }37}38 39namespace rdar9670557 {40  typedef int func(int);41  func *a();42  struct X {43    virtual func f = 0;44    virtual func (g) = 0;45    func *h = 0;46  };47}48 49namespace pr8264 {50  struct Test {51    virtual virtual void func();  // expected-warning {{duplicate 'virtual' declaration specifier}}52  };53}54 55namespace issue63503 {56struct Base {57  virtual ~Base() = default;58};59 60struct Derived final : Base {61  virtual ~Derived() = defaul; // expected-error {{use of undeclared identifier 'defaul'}}62} do_not_crash;63}64 65namespace VirtualFriend {66  // DR (filed but no number yet): reject meaningless pure-specifier on a friend declaration.67  struct A { virtual int f(); };68  struct B { friend int A::f() = 0; }; // expected-error {{friend declaration cannot have a pure-specifier}}69  struct C {70    virtual int f();71    friend int C::f() = 0; // expected-error {{friend declaration cannot have a pure-specifier}}72  };73}74