1 // RUN: %clang_cc1 -fsyntax-only -verify %s
7 void bar(int); // expected-note 2{{previous declaration is here}}
10 void foo(int); // expected-note 3{{previous declaration is here}}
13 int foo(int); // expected-error {{functions that differ only in their return type cannot be overloaded}}
14 int bar(int); // expected-error {{functions that differ only in their return type cannot be overloaded}}
15 int baz(int); // expected-note {{previous declaration is here}}
22 float foo(int); // expected-error {{functions that differ only in their return type cannot be overloaded}}
23 float bar(int); // expected-error {{functions that differ only in their return type cannot be overloaded}}
24 float baz(int); // expected-error {{functions that differ only in their return type cannot be overloaded}}
32 float foo(int); // expected-error {{functions that differ only in their return type cannot be overloaded}}
38 void typocorrection(); // expected-note {{'typocorrection' declared here}}
41 void A::Notypocorrection() { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'A'; did you mean 'typocorrection'}}
47 void Bar(); // expected-note {{'Bar' declared here}}
49 friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean 'Bar'}}
56 void typocorrection(const int); // expected-note {{'typocorrection' declared here}}
57 void typocorrection(double);
60 void B::Notypocorrection(int) { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'B'; did you mean 'typocorrection'}}
63 struct X
{ int f(); };
64 struct Y
: public X
{};
65 int Y::f() { return 3; } // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Y'}}
74 void f(test1::Foo::Inner foo
) const; // expected-note {{member declaration does not match because it is const qualified}}
79 void Bar::f(Foo::Inner foo
) { // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Bar'}}
85 void GetCart(int count
) const;
87 // This out-of-line definition was fine...
88 void Crash::cart(int count
) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}}
89 // ...while this one crashed clang
90 void Crash::chart(int count
) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'}}
94 int getit() const; // expected-note {{member declaration does not match because it is const qualified}}
95 void setit(int); // expected-note {{member declaration does not match because it is not const qualified}}
98 int TestConst::getit() { // expected-error {{out-of-line definition of 'getit' does not match any declaration in 'TestConst'}}
102 void TestConst::setit(int) const { // expected-error {{out-of-line definition of 'setit' does not match any declaration in 'TestConst'}}
105 struct J
{ int typo() const; };
106 int J::typo_() { return 3; } // expected-error {{out-of-line definition of 'typo_' does not match any declaration in 'J'}}
108 // Ensure we correct the redecl of Foo::isGood to Bar::Foo::isGood and not
109 // Foo::IsGood even though Foo::IsGood is technically a closer match since it
110 // already has a body. Also make sure Foo::beEvil is corrected to Foo::BeEvil
111 // since it is a closer match than Bar::Foo::beEvil and neither have a body.
112 namespace redecl_typo
{
114 bool IsGood() { return false; }
115 void BeEvil(); // expected-note {{'BeEvil' declared here}}
119 bool isGood(); // expected-note {{'Bar::Foo::isGood' declared here}}
123 bool Foo::isGood() { // expected-error {{out-of-line definition of 'isGood' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'Bar::Foo::isGood'?}}
126 void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}}
130 void func(int a
, int &b
); // expected-note {{type of 2nd parameter of member declaration does not match definition ('int &' vs 'int')}}
133 void CVQualFun::func(const int a
, int b
) {} // expected-error {{out-of-line definition of 'func' does not match any declaration in 'CVQualFun'}}