2011-10-18 13:54:07 +08:00
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s
2011-06-29 00:20:02 +08:00
2011-10-11 09:02:41 +08:00
namespace fizbin { class Foobar { } ; } / / expected - note 2 { { ' fizbin : : Foobar ' declared here } } \
// expected-note {{'Foobar' declared here}}
2011-09-14 06:31:32 +08:00
Foobar * my_bar // expected-error{{unknown type name 'Foobar'; did you mean 'fizbin::Foobar'?}}
2011-10-11 09:02:41 +08:00
= new Foobar ; // expected-error{{unknown type name 'Foobar'; did you mean 'fizbin::Foobar'?}}
2012-03-12 15:56:15 +08:00
fizbin : : Foobar * my_foo = new fizbin : : FooBar ; // expected-error{{no type named 'FooBar' in namespace 'fizbin'; did you mean 'Foobar'?}}
2011-06-29 00:20:02 +08:00
namespace barstool { int toFoobar ( ) { return 1 ; } } // expected-note 3 {{'barstool::toFoobar' declared here}}
int Double ( int x ) { return x + x ; }
void empty ( ) {
2011-12-15 08:38:15 +08:00
Double ( toFoobar ( ) ) ; // expected-error{{use of undeclared identifier 'toFoobar'; did you mean 'barstool::toFoobar'?}}
2011-06-29 00:20:02 +08:00
}
namespace fizbin {
namespace baztool { bool toFoobar ( ) { return true ; } } // expected-note{{'fizbin::baztool' declared here}}
namespace nested { bool moreFoobar ( ) { return true ; } } // expected-note{{'fizbin::nested::moreFoobar' declared here}}
namespace nested { bool lessFoobar ( ) { return true ; } } / / expected - note { { ' fizbin : : nested ' declared here } } \
// expected-note{{'fizbin::nested::lessFoobar' declared here}}
class dummy { // expected-note 2 {{'fizbin::dummy' declared here}}
public :
2013-09-27 03:10:29 +08:00
static bool morebar ( ) { return false ; } // expected-note{{'morebar' declared here}}
2011-06-29 00:20:02 +08:00
} ;
}
void Check ( ) { // expected-note{{'Check' declared here}}
if ( toFoobar ( ) ) Double ( 7 ) ; // expected-error{{use of undeclared identifier 'toFoobar'; did you mean 'barstool::toFoobar'?}}
if ( noFoobar ( ) ) Double ( 7 ) ; // expected-error{{use of undeclared identifier 'noFoobar'; did you mean 'barstool::toFoobar'?}}
if ( moreFoobar ( ) ) Double ( 7 ) ; // expected-error{{use of undeclared identifier 'moreFoobar'; did you mean 'fizbin::nested::moreFoobar'}}
if ( lessFoobar ( ) ) Double ( 7 ) ; // expected-error{{use of undeclared identifier 'lessFoobar'; did you mean 'fizbin::nested::lessFoobar'?}}
if ( baztool : : toFoobar ( ) ) Double ( 7 ) ; // expected-error{{use of undeclared identifier 'baztool'; did you mean 'fizbin::baztool'?}}
if ( nested : : moreFoobar ( ) ) Double ( 7 ) ; // expected-error{{use of undeclared identifier 'nested'; did you mean 'fizbin::nested'?}}
2013-09-27 03:10:29 +08:00
if ( dummy : : morebar ( ) ) Double ( 7 ) ; // expected-error{{use of undeclared identifier 'dummy'; did you mean 'fizbin::dummy'?}}
if ( dummy : : mrebar ( ) ) Double ( 7 ) ; / / expected - error { { use of undeclared identifier ' dummy ' ; did you mean ' fizbin : : dummy ' ? } } \
// expected-error{{no member named 'mrebar' in 'fizbin::dummy'; did you mean 'morebar'?}}
2011-06-29 00:20:02 +08:00
if ( moFoobin ( ) ) Double ( 7 ) ; // expected-error{{use of undeclared identifier 'moFoobin'}}
}
void Alt ( ) {
2011-12-15 08:38:15 +08:00
Cleck ( ) ; // expected-error{{use of undeclared identifier 'Cleck'; did you mean 'Check'?}}
2011-06-29 00:20:02 +08:00
}
namespace N {
namespace inner {
class myvector { /* ... */ } ; // expected-note{{'inner::myvector' declared here}}
}
void f ( ) {
2011-07-14 05:36:26 +08:00
myvector v ; // expected-error{{unknown type name 'myvector'; did you mean 'inner::myvector'?}}
2011-06-29 00:20:02 +08:00
}
}
namespace realstd {
inline namespace __1 {
class mylinkedlist { /* ... */ } ; // expected-note 2 {{'realstd::mylinkedlist' declared here}}
}
class linkedlist { /* ... */ } ;
}
void f ( ) {
2011-07-14 05:36:26 +08:00
mylinkedlist v ; // expected-error{{unknown type name 'mylinkedlist'; did you mean 'realstd::mylinkedlist'?}}
nylinkedlist w ; // expected-error{{unknown type name 'nylinkedlist'; did you mean 'realstd::mylinkedlist'?}}
}
// Test case from http://llvm.org/bugs/show_bug.cgi?id=10318
namespace llvm {
2012-03-12 15:56:15 +08:00
template < typename T > class GraphWriter { } ; // expected-note 3{{declared here}}
2011-07-14 05:36:26 +08:00
}
struct S { } ;
void bar ( ) {
GraphWriter < S > x ; //expected-error{{no template named 'GraphWriter'; did you mean 'llvm::GraphWriter'?}}
2013-03-05 14:21:38 +08:00
( void ) new llvm : : GraphWriter ; // expected-error {{use of class template 'llvm::GraphWriter' requires template arguments}}
2011-10-11 09:02:41 +08:00
( void ) new llvm : : Graphwriter < S > ; // expected-error {{no template named 'Graphwriter' in namespace 'llvm'; did you mean 'GraphWriter'?}}
2011-06-29 00:20:02 +08:00
}
2012-02-15 02:56:48 +08:00
// If namespace prefixes and character edits have the same weight, correcting
// "fimish" to "N::famish" would have the same edit distance as correcting
// "fimish" to "Finish". The result would be no correction being suggested
// unless one of the corrections is given precedence (e.g. by filtering out
// suggestions with added namespace qualifiers).
namespace N { void famish ( int ) ; }
void Finish ( int ) ; // expected-note {{'Finish' declared here}}
void Start ( ) {
fimish ( 7 ) ; // expected-error {{use of undeclared identifier 'fimish'; did you mean 'Finish'?}}
}
// But just eliminating the corrections containing added namespace qualifiers
// won't work if both of the tied corrections have namespace qualifiers added.
namespace N {
void someCheck ( int ) ; // expected-note {{'N::someCheck' declared here}}
namespace O { void somechock ( int ) ; }
}
void confusing ( ) {
somechick ( 7 ) ; // expected-error {{use of undeclared identifier 'somechick'; did you mean 'N::someCheck'?}}
}
2012-02-16 06:14:18 +08:00
class Message { } ;
namespace extra {
namespace util {
namespace MessageUtils {
bool Equivalent ( const Message & , const Message & ) ; / / expected - note { { ' extra : : util : : MessageUtils : : Equivalent ' declared here } } \
// expected-note {{'::extra::util::MessageUtils::Equivalent' declared here}}
}
}
}
namespace util { namespace MessageUtils { } }
bool nstest ( ) {
Message a , b ;
return util : : MessageUtils : : Equivalent ( a , b ) ; // expected-error {{no member named 'Equivalent' in namespace 'util::MessageUtils'; did you mean 'extra::util::MessageUtils::Equivalent'?}}
}
namespace util {
namespace extra {
bool nstest ( ) {
Message a , b ;
return MessageUtils : : Equivalent ( a , b ) ; // expected-error {{no member named 'Equivalent' in namespace 'util::MessageUtils'; did you mean '::extra::util::MessageUtils::Equivalent'?}}
}
}
}