blob: b9d1f23af4024abddd4e1ccabfc77a9156eb84f6 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor04495c82009-02-24 01:23:02 +00002int foo(int);
3
4namespace 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 Uhrain51611632011-08-18 18:19:12 +000027
28class A {
29 void typocorrection(); // expected-note {{'typocorrection' declared here}}
30};
31
32void A::Notypocorrection() { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'A'; did you mean 'typocorrection'}}
33}
34
35
36namespace 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
46class B {
Kaelyn Uhrain2afd7662011-10-11 00:28:39 +000047 void typocorrection(const int); // expected-note {{'typocorrection' declared here}}
Kaelyn Uhrain51611632011-08-18 18:19:12 +000048 void typocorrection(double);
49};
50
51void B::Notypocorrection(int) { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'B'; did you mean 'typocorrection'}}
52}
Kaelyn Uhraind2c89722011-08-18 21:57:36 +000053
54struct X { int f(); };
55struct Y : public X {};
56int Y::f() { return 3; } // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Y'}}
Matt Beaumont-Gay903d6dc2011-08-23 01:35:51 +000057
58namespace test1 {
59struct Foo {
60 class Inner { };
61};
62}
63
64class Bar {
Kaelyn Uhrain10553932011-10-10 18:01:37 +000065 void f(test1::Foo::Inner foo) const; // expected-note {{member declaration does not match because it is const qualified}}
Matt Beaumont-Gay903d6dc2011-08-23 01:35:51 +000066};
67
68using test1::Foo;
69
70void 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 Uhrain7c243342011-09-14 19:37:32 +000073
74class Crash {
75 public:
76 void GetCart(int count) const;
77};
78// This out-of-line definition was fine...
Kaelyn Uhrainef094a12012-06-07 23:57:08 +000079void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}}
Kaelyn Uhrain7c243342011-09-14 19:37:32 +000080// ...while this one crashed clang
Kaelyn Uhrainef094a12012-06-07 23:57:08 +000081void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'}}
Kaelyn Uhrain10553932011-10-10 18:01:37 +000082
83class TestConst {
84 public:
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}}
87};
88
89int TestConst::getit() { // expected-error {{out-of-line definition of 'getit' does not match any declaration in 'TestConst'}}
90 return 1;
91}
92
93void TestConst::setit(int) const { // expected-error {{out-of-line definition of 'setit' does not match any declaration in 'TestConst'}}
94}
Kaelyn Uhrain2afd7662011-10-11 00:28:39 +000095
96struct J { int typo() const; };
97int J::typo_() { return 3; } // expected-error {{out-of-line definition of 'typo_' does not match any declaration in 'J'}}
Kaelyn Uhrainef094a12012-06-07 23:57:08 +000098
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.
103namespace redecl_typo {
104namespace Foo {
105 bool IsGood() { return false; }
106 void BeEvil(); // expected-note {{'BeEvil' declared here}}
107}
108namespace Bar {
109 namespace Foo {
110 bool isGood(); // expected-note {{'Bar::Foo::isGood' declared here}}
111 void beEvil();
112 }
113}
114bool 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'?}}
115 return true;
116}
117void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}}
118}