================ @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wunnecessary-virtual-specifier %s + +struct Foo final { + Foo() = default; + virtual ~Foo() = default; // expected-warning {{virtual method}} + virtual Foo& operator=(Foo& other) = default; // expected-warning {{virtual method}} + virtual Foo& operator=(Foo&& other) = default; // expected-warning {{virtual method}} + void f(); + virtual void f(int); // expected-warning {{virtual method}} + int g(int x) { return x; }; + virtual int g(bool); // expected-warning {{virtual method}} + static int s(); +}; + +struct BarBase { + virtual ~BarBase() = delete; + virtual void virt() {} + virtual int virt(int); + int nonvirt(); +}; + +struct Bar final : BarBase { + ~Bar() override = delete; + void virt() override {}; + // `virtual ... override;` is a common pattern, so don't warn + virtual int virt(int) override; + virtual int virt(bool); // expected-warning {{virtual method}} ---------------- Endilll wrote:
But this function is always the final overrider, so what's the point of making it `virtual`? https://github.com/llvm/llvm-project/pull/131188 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits