2009-12-16 04:14:24 +08:00
// RUN: %clang_cc1 -fsyntax-only -verify %s
2009-02-24 09:23:02 +08:00
int foo ( int ) ;
namespace N {
void f1 ( ) {
void foo ( int ) ; // okay
2013-09-20 09:15:31 +08:00
void bar ( int ) ; // expected-note 2{{previous declaration is here}}
2009-02-24 09:23:02 +08:00
}
2016-06-17 05:39:46 +08:00
void foo ( int ) ; // expected-note 3{{previous declaration is here}}
2009-02-24 09:23:02 +08:00
void f2 ( ) {
2013-08-14 02:18:50 +08:00
int foo ( int ) ; // expected-error {{functions that differ only in their return type cannot be overloaded}}
2013-09-20 09:15:31 +08:00
int bar ( int ) ; // expected-error {{functions that differ only in their return type cannot be overloaded}}
2013-08-14 02:18:50 +08:00
int baz ( int ) ; // expected-note {{previous declaration is here}}
2009-02-24 09:23:02 +08:00
{
int foo ;
2013-08-14 02:18:50 +08:00
int bar ;
int baz ;
2009-02-24 09:23:02 +08:00
{
2013-08-14 02:18:50 +08:00
float foo ( int ) ; // expected-error {{functions that differ only in their return type cannot be overloaded}}
float bar ( int ) ; // expected-error {{functions that differ only in their return type cannot be overloaded}}
float baz ( int ) ; // expected-error {{functions that differ only in their return type cannot be overloaded}}
2009-02-24 09:23:02 +08:00
}
}
}
2016-06-17 05:39:46 +08:00
void f3 ( ) {
int foo ( float ) ;
{
float foo ( int ) ; // expected-error {{functions that differ only in their return type cannot be overloaded}}
}
}
2009-02-24 09:23:02 +08:00
}
2011-08-19 02:19:12 +08:00
class A {
void typocorrection ( ) ; // expected-note {{'typocorrection' declared here}}
} ;
void A : : Notypocorrection ( ) { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'A'; did you mean 'typocorrection'}}
}
namespace test0 {
void dummy ( ) {
void Bar ( ) ; // expected-note {{'Bar' declared here}}
class A {
friend void bar ( ) ; // expected-error {{no matching function 'bar' found in local scope; did you mean 'Bar'}}
} ;
}
}
class B {
2011-10-11 08:28:39 +08:00
void typocorrection ( const int ) ; // expected-note {{'typocorrection' declared here}}
2011-08-19 02:19:12 +08:00
void typocorrection ( double ) ;
} ;
void B : : Notypocorrection ( int ) { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'B'; did you mean 'typocorrection'}}
}
2011-08-19 05:57:36 +08:00
struct X { int f ( ) ; } ;
struct Y : public X { } ;
int Y : : f ( ) { return 3 ; } // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Y'}}
2011-08-23 09:35:51 +08:00
namespace test1 {
struct Foo {
class Inner { } ;
} ;
}
class Bar {
2011-10-11 02:01:37 +08:00
void f ( test1 : : Foo : : Inner foo ) const ; // expected-note {{member declaration does not match because it is const qualified}}
2011-08-23 09:35:51 +08:00
} ;
using test1 : : Foo ;
void Bar : : f ( Foo : : Inner foo ) { // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Bar'}}
( void ) foo ;
}
2011-09-15 03:37:32 +08:00
class Crash {
public :
void GetCart ( int count ) const ;
} ;
// This out-of-line definition was fine...
2012-06-08 07:57:08 +08:00
void Crash : : cart ( int count ) const { } // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}}
2011-09-15 03:37:32 +08:00
// ...while this one crashed clang
2012-06-08 07:57:08 +08:00
void Crash : : chart ( int count ) const { } // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'}}
2011-10-11 02:01:37 +08:00
class TestConst {
public :
int getit ( ) const ; // expected-note {{member declaration does not match because it is const qualified}}
void setit ( int ) ; // expected-note {{member declaration does not match because it is not const qualified}}
} ;
int TestConst : : getit ( ) { // expected-error {{out-of-line definition of 'getit' does not match any declaration in 'TestConst'}}
return 1 ;
}
void TestConst : : setit ( int ) const { // expected-error {{out-of-line definition of 'setit' does not match any declaration in 'TestConst'}}
}
2011-10-11 08:28:39 +08:00
struct J { int typo ( ) const ; } ;
int J : : typo_ ( ) { return 3 ; } // expected-error {{out-of-line definition of 'typo_' does not match any declaration in 'J'}}
2012-06-08 07:57:08 +08:00
// Ensure we correct the redecl of Foo::isGood to Bar::Foo::isGood and not
// Foo::IsGood even though Foo::IsGood is technically a closer match since it
// already has a body. Also make sure Foo::beEvil is corrected to Foo::BeEvil
// since it is a closer match than Bar::Foo::beEvil and neither have a body.
namespace redecl_typo {
namespace Foo {
bool IsGood ( ) { return false ; }
void BeEvil ( ) ; // expected-note {{'BeEvil' declared here}}
}
namespace Bar {
namespace Foo {
bool isGood ( ) ; // expected-note {{'Bar::Foo::isGood' declared here}}
void beEvil ( ) ;
}
}
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'?}}
return true ;
}
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'?}}
}