2011-10-14 06:29:44 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++11 %s
|
2009-01-10 03:57:06 +08:00
|
|
|
|
|
|
|
class A {
|
|
|
|
virtual void f();
|
2011-06-25 08:56:27 +08:00
|
|
|
virtual void g() = 0; // expected-note{{unimplemented pure virtual method 'g' in 'A'}}
|
2009-01-10 03:57:06 +08:00
|
|
|
|
|
|
|
void h() = 0; // expected-error {{'h' is not virtual and cannot be declared pure}}
|
|
|
|
void i() = 1; // expected-error {{initializer on function does not look like a pure-specifier}}
|
|
|
|
void j() = 0u; // expected-error {{initializer on function does not look like a pure-specifier}}
|
|
|
|
|
2009-03-12 07:00:04 +08:00
|
|
|
|
|
|
|
void k();
|
|
|
|
|
2009-01-10 03:57:06 +08:00
|
|
|
public:
|
|
|
|
A(int);
|
|
|
|
};
|
|
|
|
|
2009-03-12 07:00:04 +08:00
|
|
|
virtual void A::k() { } // expected-error{{'virtual' can only be specified inside the class definition}}
|
|
|
|
|
2009-01-10 03:57:06 +08:00
|
|
|
class B : public A {
|
|
|
|
// Needs to recognize that overridden function is virtual.
|
2011-06-25 08:56:27 +08:00
|
|
|
void g() = 0;
|
2009-01-10 03:57:06 +08:00
|
|
|
|
|
|
|
// Needs to recognize that function does not override.
|
2011-06-25 08:56:27 +08:00
|
|
|
void g(int) = 0; // expected-error{{'g' is not virtual and cannot be declared pure}}
|
2009-01-10 03:57:06 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Needs to recognize invalid uses of abstract classes.
|
2011-06-25 08:56:27 +08:00
|
|
|
A fn(A) // expected-error{{parameter type 'A' is an abstract class}} \
|
|
|
|
// expected-error{{return type 'A' is an abstract class}}
|
2009-01-10 03:57:06 +08:00
|
|
|
{
|
2011-06-25 08:56:27 +08:00
|
|
|
A a; // expected-error{{variable type 'A' is an abstract class}}
|
2012-05-07 09:10:33 +08:00
|
|
|
(void)static_cast<A>(0); // expected-error{{allocating an object of abstract class type 'A'}}
|
2009-01-10 03:57:06 +08:00
|
|
|
try {
|
2011-06-25 08:56:27 +08:00
|
|
|
} catch(A) { // expected-error{{variable type 'A' is an abstract class}}
|
2009-01-10 03:57:06 +08:00
|
|
|
}
|
|
|
|
}
|
2011-06-25 08:56:27 +08:00
|
|
|
|
|
|
|
namespace rdar9670557 {
|
|
|
|
typedef int func(int);
|
2011-06-25 10:28:38 +08:00
|
|
|
func *a();
|
2011-06-25 08:56:27 +08:00
|
|
|
struct X {
|
|
|
|
virtual func f = 0;
|
2011-06-25 10:28:38 +08:00
|
|
|
virtual func (g) = 0;
|
|
|
|
func *h = 0;
|
2011-06-25 08:56:27 +08:00
|
|
|
};
|
|
|
|
}
|
2013-11-13 14:57:53 +08:00
|
|
|
|
|
|
|
namespace pr8264 {
|
|
|
|
struct Test {
|
|
|
|
virtual virtual void func(); // expected-warning {{duplicate 'virtual' declaration specifier}}
|
|
|
|
};
|
|
|
|
}
|