[lld][WebAssembly] Reinstate mistakenly disabled test. NFC
[llvm-project.git] / clang / test / SemaCXX / virtuals.cpp
blobf8180745bd3ba5b9a4a5c2d6e9c57c5fa3919815
1 // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++11 %s
3 class A {
4 virtual void f();
5 virtual void g() = 0; // expected-note{{unimplemented pure virtual method 'g' in 'A'}}
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}}
12 void k();
14 public:
15 A(int);
18 virtual void A::k() { } // expected-error{{'virtual' can only be specified inside the class definition}}
20 class B : public A {
21 // Needs to recognize that overridden function is virtual.
22 void g() = 0;
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}}
28 // Needs to recognize invalid uses of abstract classes.
29 A fn(A) // expected-error{{parameter type 'A' is an abstract class}} \
30 // expected-error{{return type 'A' is an abstract class}}
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}}
39 namespace 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;
49 namespace pr8264 {
50 struct Test {
51 virtual virtual void func(); // expected-warning {{duplicate 'virtual' declaration specifier}}
55 namespace VirtualFriend {
56 // DR (filed but no number yet): reject meaningless pure-specifier on a friend declaration.
57 struct A { virtual int f(); };
58 struct B { friend int A::f() = 0; }; // expected-error {{friend declaration cannot have a pure-specifier}}
59 struct C {
60 virtual int f();
61 friend int C::f() = 0; // expected-error {{friend declaration cannot have a pure-specifier}}