1 // RUN: %clang_cc1 -fsyntax-only -Woverloaded-virtual -verify %s
4 virtual void foo(int); // expected-note {{declared here}}
5 virtual void foo(); // expected-note {{declared here}}
8 struct S1
: public B1
{
9 void foo(float); // expected-warning {{hides overloaded virtual functions}}
12 struct S2
: public B1
{
13 void foo(); // expected-note {{declared here}}
17 virtual void foo(void*); // expected-note {{declared here}}
20 struct MS1
: public S2
, public B2
{
21 virtual void foo(int); // expected-warning {{hides overloaded virtual functions}}
25 virtual void foo(int);
29 struct S3
: public B3
{
38 struct S4
: public B4
{
45 virtual void foo(int);
48 void Base::foo(int) { }
50 struct Derived
: public Base
{
51 virtual void foo(int);
59 virtual void f(int) {}
68 namespace ThreeLayer
{
84 namespace UnbalancedVirtual
{
89 struct Derived1
: virtual Base
{
93 struct Derived2
: virtual Base
{
96 struct MostDerived
: Derived1
, Derived2
{
102 namespace UnbalancedVirtual2
{
107 struct Derived1
: virtual Base
{
111 struct Derived2
: virtual Base
{
114 struct Derived3
: Derived1
{
118 struct MostDerived
: Derived3
, Derived2
{
126 virtual int foo(bool) const;
127 // expected-note@-1{{type mismatch at 1st parameter ('bool' vs 'int')}}
128 virtual int foo(int, int) const;
129 // expected-note@-1{{different number of parameters (2 vs 1)}}
130 virtual int foo(int*) const;
131 // expected-note@-1{{type mismatch at 1st parameter ('int *' vs 'int')}}
132 virtual int foo(int) volatile;
133 // expected-note@-1{{different qualifiers ('volatile' vs 'const')}}
137 virtual int foo(int) const;
138 // expected-warning@-1{{hides overloaded virtual functions}}
147 struct derived
: base
{
151 void foo(derived
&d
) {
152 d
.f('1'); // FIXME: this should warn about calling (anonymous namespace)::derived::f(int)
153 // instead of (anonymous namespace)::base::f(char).
154 // Note: this should be under a new diagnostic flag and eventually moved to a
155 // new test case since it's not strictly related to virtual functions.
156 d
.f(12); // This should not warn.