2017-03-01 22:41:11 +08:00
|
|
|
// RUN: %check_clang_tidy %s modernize-use-override %t -- -- -std=c++11 -fexceptions
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
#define ABSTRACT = 0
|
|
|
|
|
|
|
|
#define OVERRIDE override
|
|
|
|
#define VIRTUAL virtual
|
|
|
|
#define NOT_VIRTUAL
|
|
|
|
#define NOT_OVERRIDE
|
|
|
|
|
|
|
|
#define MUST_USE_RESULT __attribute__((warn_unused_result))
|
2014-11-25 18:45:23 +08:00
|
|
|
#define UNUSED __attribute__((unused))
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
struct MUST_USE_RESULT MustUseResultObject {};
|
|
|
|
|
2017-07-07 18:15:24 +08:00
|
|
|
struct IntPair {
|
|
|
|
int First, Second;
|
|
|
|
};
|
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
struct Base {
|
|
|
|
virtual ~Base() {}
|
|
|
|
virtual void a();
|
|
|
|
virtual void b();
|
|
|
|
virtual void c();
|
|
|
|
virtual void d();
|
2015-02-28 00:50:32 +08:00
|
|
|
virtual void d2();
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual void e() = 0;
|
|
|
|
virtual void f() = 0;
|
2016-04-04 22:31:36 +08:00
|
|
|
virtual void f2() const = 0;
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual void g() = 0;
|
|
|
|
|
|
|
|
virtual void j() const;
|
|
|
|
virtual MustUseResultObject k();
|
2014-11-25 18:45:23 +08:00
|
|
|
virtual bool l() MUST_USE_RESULT UNUSED;
|
2014-11-25 20:32:14 +08:00
|
|
|
virtual bool n() MUST_USE_RESULT UNUSED;
|
2014-06-11 20:18:24 +08:00
|
|
|
|
|
|
|
virtual void m();
|
2015-02-28 00:50:32 +08:00
|
|
|
virtual void m2();
|
2015-01-09 21:56:35 +08:00
|
|
|
virtual void o() __attribute__((unused));
|
2015-08-19 10:05:37 +08:00
|
|
|
|
|
|
|
virtual void r() &;
|
|
|
|
virtual void rr() &&;
|
|
|
|
|
|
|
|
virtual void cv() const volatile;
|
|
|
|
virtual void cv2() const volatile;
|
2016-01-13 05:08:27 +08:00
|
|
|
|
|
|
|
virtual void ne() noexcept(false);
|
|
|
|
virtual void t() throw();
|
2017-07-07 18:15:24 +08:00
|
|
|
|
|
|
|
virtual void il(IntPair);
|
2014-06-04 16:26:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SimpleCases : public Base {
|
|
|
|
public:
|
|
|
|
virtual ~SimpleCases();
|
2015-08-31 21:17:43 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} ~SimpleCases() override;
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
void a();
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void a() override;
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
void b() override;
|
2014-07-10 05:09:26 +08:00
|
|
|
// CHECK-MESSAGES-NOT: warning:
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void b() override;
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual void c();
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void c() override;
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual void d() override;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'override'
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void d() override;
|
2014-06-04 16:26:02 +08:00
|
|
|
|
2015-02-28 00:50:32 +08:00
|
|
|
virtual void d2() final;
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'final'
|
|
|
|
// CHECK-FIXES: {{^}} void d2() final;
|
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual void e() = 0;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void e() override = 0;
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual void f()=0;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2016-04-04 22:31:36 +08:00
|
|
|
// CHECK-FIXES: {{^}} void f() override =0;
|
|
|
|
|
|
|
|
virtual void f2() const=0;
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
|
|
|
// CHECK-FIXES: {{^}} void f2() const override =0;
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual void g() ABSTRACT;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void g() override ABSTRACT;
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
virtual void j() const;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void j() const override;
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual MustUseResultObject k(); // Has an implicit attribute.
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} MustUseResultObject k() override;
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-11-25 18:45:23 +08:00
|
|
|
virtual bool l() MUST_USE_RESULT UNUSED;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} bool l() override MUST_USE_RESULT UNUSED;
|
2014-06-11 20:18:24 +08:00
|
|
|
|
2014-11-25 20:32:14 +08:00
|
|
|
virtual bool n() UNUSED MUST_USE_RESULT;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} bool n() override UNUSED MUST_USE_RESULT;
|
2014-11-25 20:32:14 +08:00
|
|
|
|
2015-02-28 00:50:32 +08:00
|
|
|
void m() override final;
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: 'override' is redundant since the function is already declared 'final'
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void m() final;
|
2015-01-09 21:56:35 +08:00
|
|
|
|
2015-02-28 00:50:32 +08:00
|
|
|
virtual void m2() override final;
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' and 'override' are redundant since the function is already declared 'final'
|
|
|
|
// CHECK-FIXES: {{^}} void m2() final;
|
|
|
|
|
2015-01-09 21:56:35 +08:00
|
|
|
virtual void o() __attribute__((unused));
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void o() override __attribute__((unused));
|
2016-01-13 05:08:27 +08:00
|
|
|
|
|
|
|
virtual void ne() noexcept(false);
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
|
|
|
// CHECK-FIXES: {{^}} void ne() noexcept(false) override;
|
|
|
|
|
|
|
|
virtual void t() throw();
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
|
|
|
// CHECK-FIXES: {{^}} void t() throw() override;
|
2014-06-04 16:26:02 +08:00
|
|
|
};
|
|
|
|
|
2014-07-10 05:09:26 +08:00
|
|
|
// CHECK-MESSAGES-NOT: warning:
|
|
|
|
|
2014-07-12 21:16:58 +08:00
|
|
|
void SimpleCases::c() {}
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}}void SimpleCases::c() {}
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
SimpleCases::~SimpleCases() {}
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}}SimpleCases::~SimpleCases() {}
|
2014-06-04 16:26:02 +08:00
|
|
|
|
2014-06-20 17:12:46 +08:00
|
|
|
struct DefaultedDestructor : public Base {
|
|
|
|
DefaultedDestructor() {}
|
|
|
|
virtual ~DefaultedDestructor() = default;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} ~DefaultedDestructor() override = default;
|
2014-06-20 17:12:46 +08:00
|
|
|
};
|
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
struct FinalSpecified : public Base {
|
|
|
|
public:
|
|
|
|
virtual ~FinalSpecified() final;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 'virtual' is redundant since the function is already declared 'final'
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} ~FinalSpecified() final;
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
void b() final;
|
2014-07-10 05:09:26 +08:00
|
|
|
// CHECK-MESSAGES-NOT: warning:
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void b() final;
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual void d() final;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void d() final;
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
virtual void e() final = 0;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void e() final = 0;
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
virtual void j() const final;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void j() const final;
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-11-25 18:45:23 +08:00
|
|
|
virtual bool l() final MUST_USE_RESULT UNUSED;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} bool l() final MUST_USE_RESULT UNUSED;
|
2014-06-04 16:26:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct InlineDefinitions : public Base {
|
|
|
|
public:
|
|
|
|
virtual ~InlineDefinitions() {}
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} ~InlineDefinitions() override {}
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
void a() {}
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void a() override {}
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
void b() override {}
|
2014-07-10 05:09:26 +08:00
|
|
|
// CHECK-MESSAGES-NOT: warning:
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void b() override {}
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2015-08-19 10:05:37 +08:00
|
|
|
virtual void c()
|
|
|
|
{}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
|
|
|
|
// CHECK-FIXES: {{^}} void c() override
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual void d() override {}
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void d() override {}
|
2014-06-04 16:26:02 +08:00
|
|
|
|
2015-08-19 10:05:37 +08:00
|
|
|
virtual void j() const
|
|
|
|
{}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
|
|
|
|
// CHECK-FIXES: {{^}} void j() const override
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
virtual MustUseResultObject k() {} // Has an implicit attribute.
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} MustUseResultObject k() override {}
|
2014-07-10 05:09:26 +08:00
|
|
|
|
2014-11-25 18:45:23 +08:00
|
|
|
virtual bool l() MUST_USE_RESULT UNUSED {}
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} bool l() override MUST_USE_RESULT UNUSED {}
|
2015-08-19 10:05:37 +08:00
|
|
|
|
|
|
|
virtual void r() &
|
|
|
|
{}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
|
|
|
|
// CHECK-FIXES: {{^}} void r() & override
|
|
|
|
|
|
|
|
virtual void rr() &&
|
|
|
|
{}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
|
|
|
|
// CHECK-FIXES: {{^}} void rr() && override
|
|
|
|
|
|
|
|
virtual void cv() const volatile
|
|
|
|
{}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
|
|
|
|
// CHECK-FIXES: {{^}} void cv() const volatile override
|
|
|
|
|
|
|
|
virtual void cv2() const volatile // some comment
|
|
|
|
{}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
|
|
|
|
// CHECK-FIXES: {{^}} void cv2() const volatile override // some comment
|
2014-06-04 16:26:02 +08:00
|
|
|
};
|
|
|
|
|
2017-07-07 18:15:24 +08:00
|
|
|
struct DefaultArguments : public Base {
|
|
|
|
// Tests for default arguments (with initializer lists).
|
|
|
|
// Make sure the override fix is placed after the argument list.
|
|
|
|
void il(IntPair p = {1, (2 + (3))}) {}
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
|
|
|
|
// CHECK-FIXES: {{^}} void il(IntPair p = {1, (2 + (3))}) override {}
|
|
|
|
};
|
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
struct Macros : public Base {
|
|
|
|
// Tests for 'virtual' and 'override' being defined through macros. Basically
|
|
|
|
// give up for now.
|
|
|
|
NOT_VIRTUAL void a() NOT_OVERRIDE;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: annotate this
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} NOT_VIRTUAL void a() override NOT_OVERRIDE;
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
VIRTUAL void b() NOT_OVERRIDE;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} VIRTUAL void b() override NOT_OVERRIDE;
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
NOT_VIRTUAL void c() OVERRIDE;
|
2014-07-10 05:09:26 +08:00
|
|
|
// CHECK-MESSAGES-NOT: warning:
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} NOT_VIRTUAL void c() OVERRIDE;
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
VIRTUAL void d() OVERRIDE;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} VIRTUAL void d() OVERRIDE;
|
2014-06-04 16:26:02 +08:00
|
|
|
|
2014-07-12 21:16:58 +08:00
|
|
|
#define FUNC(return_type, name) return_type name()
|
2014-06-04 16:26:02 +08:00
|
|
|
FUNC(void, e);
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} FUNC(void, e);
|
2014-06-04 16:26:02 +08:00
|
|
|
|
|
|
|
#define F virtual void f();
|
|
|
|
F
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} F
|
2014-06-11 20:18:24 +08:00
|
|
|
|
|
|
|
VIRTUAL void g() OVERRIDE final;
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' and 'override' are redundant
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} VIRTUAL void g() final;
|
2014-06-04 16:26:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Tests for templates.
|
|
|
|
template <typename T> struct TemplateBase {
|
|
|
|
virtual void f(T t);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T> struct DerivedFromTemplate : public TemplateBase<T> {
|
|
|
|
virtual void f(T t);
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void f(T t) override;
|
2014-06-04 16:26:02 +08:00
|
|
|
};
|
|
|
|
void f() { DerivedFromTemplate<int>().f(2); }
|
|
|
|
|
|
|
|
template <class C>
|
|
|
|
struct UnusedMemberInstantiation : public C {
|
|
|
|
virtual ~UnusedMemberInstantiation() {}
|
2015-02-28 00:50:32 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} ~UnusedMemberInstantiation() override {}
|
2014-06-04 16:26:02 +08:00
|
|
|
};
|
|
|
|
struct IntantiateWithoutUse : public UnusedMemberInstantiation<Base> {};
|
|
|
|
|
2014-07-12 21:16:58 +08:00
|
|
|
struct Base2 {
|
|
|
|
virtual ~Base2() {}
|
|
|
|
virtual void a();
|
|
|
|
};
|
|
|
|
|
2014-06-04 16:26:02 +08:00
|
|
|
// The OverrideAttr isn't propagated to specializations in all cases. Make sure
|
|
|
|
// we don't add "override" a second time.
|
|
|
|
template <int I>
|
2014-07-12 21:16:58 +08:00
|
|
|
struct MembersOfSpecializations : public Base2 {
|
2014-06-04 16:26:02 +08:00
|
|
|
void a() override;
|
2014-07-10 05:09:26 +08:00
|
|
|
// CHECK-MESSAGES-NOT: warning:
|
2015-01-09 22:10:15 +08:00
|
|
|
// CHECK-FIXES: {{^}} void a() override;
|
2014-06-04 16:26:02 +08:00
|
|
|
};
|
|
|
|
template <> void MembersOfSpecializations<3>::a() {}
|
2014-07-12 21:16:58 +08:00
|
|
|
void ff() { MembersOfSpecializations<3>().a(); };
|
2017-03-01 18:16:36 +08:00
|
|
|
|
|
|
|
// In case try statement is used as a method body,
|
|
|
|
// make sure that override fix is placed before try keyword.
|
|
|
|
struct TryStmtAsBody : public Base {
|
|
|
|
void a() try
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
|
|
|
|
// CHECK-FIXES: {{^}} void a() override try
|
|
|
|
{ b(); } catch(...) { c(); }
|
|
|
|
|
|
|
|
virtual void d() try
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
|
|
|
|
// CHECK-FIXES: {{^}} void d() override try
|
|
|
|
{ e(); } catch(...) { f(); }
|
|
|
|
};
|