1 // RUN: %clang_cc1 -fsyntax-only -verify %s
9 // FIXME: we shouldn't even need this declaration to detect errors
11 void foo(int); // expected-note{{previous declaration is here}}
14 int foo(int); // expected-error{{functions that differ only in their return type cannot be overloaded}}
19 // FIXME: should diagnose this because it's incompatible with
20 // N::foo. However, name lookup isn't properly "skipping" the
29 void typocorrection(); // expected-note {{'typocorrection' declared here}}
32 void A::Notypocorrection() { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'A'; did you mean 'typocorrection'}}
38 void Bar(); // expected-note {{'Bar' declared here}}
40 friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean 'Bar'}}
47 void typocorrection(const int); // expected-note {{'typocorrection' declared here}}
48 void typocorrection(double);
51 void B::Notypocorrection(int) { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'B'; did you mean 'typocorrection'}}
54 struct X { int f(); };
55 struct Y : public X {};
56 int Y::f() { return 3; } // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Y'}}
65 void f(test1::Foo::Inner foo) const; // expected-note {{member declaration does not match because it is const qualified}}
70 void Bar::f(Foo::Inner foo) { // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Bar'}}
76 void GetCart(int count) const;
78 // This out-of-line definition was fine...
79 void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}}
80 // ...while this one crashed clang
81 void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'}}
85 int getit() const; // expected-note {{member declaration does not match because it is const qualified}}
86 void setit(int); // expected-note {{member declaration does not match because it is not const qualified}}
89 int TestConst::getit() { // expected-error {{out-of-line definition of 'getit' does not match any declaration in 'TestConst'}}
93 void TestConst::setit(int) const { // expected-error {{out-of-line definition of 'setit' does not match any declaration in 'TestConst'}}
96 struct J { int typo() const; };
97 int J::typo_() { return 3; } // expected-error {{out-of-line definition of 'typo_' does not match any declaration in 'J'}}
99 // Ensure we correct the redecl of Foo::isGood to Bar::Foo::isGood and not
100 // Foo::IsGood even though Foo::IsGood is technically a closer match since it
101 // already has a body. Also make sure Foo::beEvil is corrected to Foo::BeEvil
102 // since it is a closer match than Bar::Foo::beEvil and neither have a body.
103 namespace redecl_typo {
105 bool IsGood() { return false; }
106 void BeEvil(); // expected-note {{'BeEvil' declared here}}
110 bool isGood(); // expected-note {{'Bar::Foo::isGood' declared here}}
114 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'?}}
117 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'?}}