Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 04495c8 | 2009-02-24 01:23:02 +0000 | [diff] [blame] | 2 | int foo(int); |
| 3 | |
| 4 | namespace N { |
| 5 | void f1() { |
| 6 | void foo(int); // okay |
| 7 | } |
| 8 | |
| 9 | // FIXME: we shouldn't even need this declaration to detect errors |
| 10 | // below. |
| 11 | void foo(int); // expected-note{{previous declaration is here}} |
| 12 | |
| 13 | void f2() { |
| 14 | int foo(int); // expected-error{{functions that differ only in their return type cannot be overloaded}} |
| 15 | |
| 16 | { |
| 17 | int foo; |
| 18 | { |
| 19 | // FIXME: should diagnose this because it's incompatible with |
| 20 | // N::foo. However, name lookup isn't properly "skipping" the |
| 21 | // "int foo" above. |
| 22 | float foo(int); |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | } |
Kaelyn Uhrain | 5161163 | 2011-08-18 18:19:12 +0000 | [diff] [blame] | 27 | |
| 28 | class A { |
| 29 | void typocorrection(); // expected-note {{'typocorrection' declared here}} |
| 30 | }; |
| 31 | |
| 32 | void A::Notypocorrection() { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'A'; did you mean 'typocorrection'}} |
| 33 | } |
| 34 | |
| 35 | |
| 36 | namespace test0 { |
| 37 | void dummy() { |
| 38 | void Bar(); // expected-note {{'Bar' declared here}} |
| 39 | class A { |
| 40 | friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean 'Bar'}} |
| 41 | }; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | |
| 46 | class B { |
Kaelyn Uhrain | 2afd766 | 2011-10-11 00:28:39 +0000 | [diff] [blame] | 47 | void typocorrection(const int); // expected-note {{'typocorrection' declared here}} |
Kaelyn Uhrain | 5161163 | 2011-08-18 18:19:12 +0000 | [diff] [blame] | 48 | void typocorrection(double); |
| 49 | }; |
| 50 | |
| 51 | void B::Notypocorrection(int) { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'B'; did you mean 'typocorrection'}} |
| 52 | } |
Kaelyn Uhrain | d2c8972 | 2011-08-18 21:57:36 +0000 | [diff] [blame] | 53 | |
| 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'}} |
Matt Beaumont-Gay | 903d6dc | 2011-08-23 01:35:51 +0000 | [diff] [blame] | 57 | |
| 58 | namespace test1 { |
| 59 | struct Foo { |
| 60 | class Inner { }; |
| 61 | }; |
| 62 | } |
| 63 | |
| 64 | class Bar { |
Kaelyn Uhrain | 1055393 | 2011-10-10 18:01:37 +0000 | [diff] [blame] | 65 | void f(test1::Foo::Inner foo) const; // expected-note {{member declaration does not match because it is const qualified}} |
Matt Beaumont-Gay | 903d6dc | 2011-08-23 01:35:51 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | using test1::Foo; |
| 69 | |
| 70 | void Bar::f(Foo::Inner foo) { // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Bar'}} |
| 71 | (void)foo; |
| 72 | } |
Kaelyn Uhrain | 7c24334 | 2011-09-14 19:37:32 +0000 | [diff] [blame] | 73 | |
| 74 | class Crash { |
| 75 | public: |
| 76 | void GetCart(int count) const; |
| 77 | }; |
| 78 | // This out-of-line definition was fine... |
Nick Lewycky | 173a37a | 2012-04-03 21:44:08 +0000 | [diff] [blame] | 79 | void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}} \ |
| 80 | // expected-note {{'cart' declared here}} \ |
| 81 | // expected-note {{previous definition is here}} |
Kaelyn Uhrain | 7c24334 | 2011-09-14 19:37:32 +0000 | [diff] [blame] | 82 | // ...while this one crashed clang |
Nick Lewycky | 173a37a | 2012-04-03 21:44:08 +0000 | [diff] [blame] | 83 | void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'; did you mean 'cart'?}} \ |
| 84 | // expected-error {{redefinition of 'cart'}} |
Kaelyn Uhrain | 1055393 | 2011-10-10 18:01:37 +0000 | [diff] [blame] | 85 | |
| 86 | class TestConst { |
| 87 | public: |
| 88 | int getit() const; // expected-note {{member declaration does not match because it is const qualified}} |
| 89 | void setit(int); // expected-note {{member declaration does not match because it is not const qualified}} |
| 90 | }; |
| 91 | |
| 92 | int TestConst::getit() { // expected-error {{out-of-line definition of 'getit' does not match any declaration in 'TestConst'}} |
| 93 | return 1; |
| 94 | } |
| 95 | |
| 96 | void TestConst::setit(int) const { // expected-error {{out-of-line definition of 'setit' does not match any declaration in 'TestConst'}} |
| 97 | } |
Kaelyn Uhrain | 2afd766 | 2011-10-11 00:28:39 +0000 | [diff] [blame] | 98 | |
| 99 | struct J { int typo() const; }; |
| 100 | int J::typo_() { return 3; } // expected-error {{out-of-line definition of 'typo_' does not match any declaration in 'J'}} |