1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // RUN: not %clang_cc1 -fsyntax-only -fixit -x c++ %t
4 // RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t
5 // RUN: grep test_string %t
8 template<typename T
> class basic_string
{ // expected-note 3{{'basic_string' declared here}}
10 int find(const char *substr
); // expected-note{{'find' declared here}}
11 static const int npos
= -1; // expected-note{{'npos' declared here}}
14 typedef basic_string
<char> string
; // expected-note 2{{'string' declared here}}
17 namespace otherstd
{ // expected-note 2{{'otherstd' declared here}} \
18 // expected-note{{namespace 'otherstd' defined here}}
24 other_std::strng str1
; // expected-error{{use of undeclared identifier 'other_std'; did you mean 'otherstd'?}} \
25 // expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
26 tring str2
; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
28 ::other_std::string str3
; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
30 float area(float radius
, // expected-note{{'radius' declared here}}
32 return radious
* pi
; // expected-error{{did you mean 'radius'?}}
35 using namespace othestd
; // expected-error{{no namespace named 'othestd'; did you mean 'otherstd'?}}
36 namespace blargh
= otherstd
; // expected-note 3{{namespace 'blargh' defined here}}
37 using namespace ::blarg
; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
39 namespace wibble
= blarg
; // expected-error{{no namespace named 'blarg'; did you mean 'blargh'?}}
40 namespace wobble
= ::blarg
; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
42 bool test_string(std::string s
) {
43 basc_string
<char> b1
; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}}
44 std::basic_sting
<char> b2
; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}}
47 return s
.fnd("hello") // expected-error{{no member named 'fnd' in 'std::basic_string<char>'; did you mean 'find'?}}
48 == std::string::pos
; // expected-error{{no member named 'pos' in 'std::basic_string<char>'; did you mean 'npos'?}}
52 struct Derived
: public Base
{ // expected-note{{base class 'Base' specified here}}
53 int member
; // expected-note 3{{'member' declared here}}
55 Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}
56 ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}}
58 int getMember() const {
59 return ember
; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
65 int &Derived::getMember() {
66 return ember
; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
69 typedef int Integer
; // expected-note{{'Integer' declared here}}
70 int global_value
; // expected-note{{'global_value' declared here}}
73 integer
* i
= 0; // expected-error{{unknown type name 'integer'; did you mean 'Integer'?}}
74 unsinged
*ptr
= 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
75 return *i
+ *ptr
+ global_val
; // expected-error{{use of undeclared identifier 'global_val'; did you mean 'global_value'?}}
79 typedef std::basic_string
<char> yarn
; // expected-note 2 {{'nonstd::yarn' declared here}}
80 int narf
; // expected-note{{'nonstd::narf' declared here}}
83 yarn str4
; // expected-error{{unknown type name 'yarn'; did you mean 'nonstd::yarn'?}}
84 wibble::yarn str5
; // expected-error{{no type named 'yarn' in namespace 'otherstd'; did you mean 'nonstd::yarn'?}}
87 template<typename T
> class wide_string
{}; // expected-note {{'another::wide_string' declared here}}
90 nonstd::basic_string
<char> str
; // expected-error{{no template named 'basic_string' in namespace 'nonstd'; did you mean simply 'basic_string'?}}
91 nonstd::wide_string
<char> str2
; // expected-error{{no template named 'wide_string' in namespace 'nonstd'; did you mean 'another::wide_string'?}}
92 return wibble::narf
; // expected-error{{no member named 'narf' in namespace 'otherstd'; did you mean 'nonstd::narf'?}}
95 namespace check_bool
{
97 Bool b
; // expected-error{{use of undeclared identifier 'Bool'; did you mean 'bool'?}}
104 namespace inner
{ // expected-note{{'outer::inner' declared here}} \
105 // expected-note{{namespace 'outer::inner' defined here}} \
106 // expected-note{{'inner' declared here}}
111 using namespace outr::inner
; // expected-error{{no namespace named 'inner' in namespace 'outr'; did you mean 'outer::inner'?}}
114 outr::inner::i
= 3; // expected-error{{no member named 'inner' in namespace 'outr'; did you mean 'outer::inner'?}}
115 outer::innr::i
= 4; // expected-error{{no member named 'innr' in namespace 'outer'; did you mean 'inner'?}}
120 struct derived
: base
{
126 // FIXME: we should offer a fix here. We do if the 'i' is misspelled, but we don't do name qualification changes
127 // to replace base::i with derived::i as we would for other qualified name misspellings.
134 void bar(int, int); // expected-note{{'::bar' declared here}}
136 bar(x
, 5); // expected-error{{too many arguments to function call, expected 1, have 2; did you mean '::bar'?}}