blob: c0570258c53b5b75951729e71ab47f794fb68d22 [file] [log] [blame]
Douglas Gregor2d435302009-12-30 17:04:44 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor3f8f4472010-01-01 17:23:17 +00002// RUN: %clang_cc1 -fsyntax-only -fixit -o - %s | %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ -
Douglas Gregor2d435302009-12-30 17:04:44 +00003namespace std {
Douglas Gregor6da83622010-01-07 00:17:44 +00004 template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}}
5 int find(const char *substr); // expected-note{{'find' declared here}}
6 static const int npos = -1; // expected-note{{'npos' declared here}}
Douglas Gregor598b08f2009-12-31 05:20:13 +00007 };
8
Douglas Gregor6da83622010-01-07 00:17:44 +00009 typedef basic_string<char> string; // expected-note 2{{'string' declared here}}
Douglas Gregor2d435302009-12-30 17:04:44 +000010}
11
Douglas Gregor6da83622010-01-07 00:17:44 +000012namespace otherstd { // expected-note 2{{'otherstd' declared here}}
Douglas Gregor2d435302009-12-30 17:04:44 +000013 using namespace std;
14}
15
16using namespace std;
17
Douglas Gregor532e68f2009-12-31 08:26:35 +000018other_std::strng str1; // expected-error{{use of undeclared identifier 'other_std'; did you mean 'otherstd'?}} \
19// expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
Douglas Gregor2d435302009-12-30 17:04:44 +000020tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
Douglas Gregor598b08f2009-12-31 05:20:13 +000021
Douglas Gregor103dae42009-12-31 08:27:32 +000022::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
23
Douglas Gregor712dcfe2010-01-07 00:31:29 +000024float area(float radius, // expected-note{{'radius' declared here}}
25 float pi) {
26 return radious * pi; // expected-error{{did you mean 'radius'?}}
Douglas Gregor598b08f2009-12-31 05:20:13 +000027}
28
29bool test_string(std::string s) {
Douglas Gregorff18cc12009-12-31 08:11:17 +000030 basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}}
31 std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}}
32 (void)b1;
33 (void)b2;
Douglas Gregoraf2bd472009-12-31 07:42:17 +000034 return s.fnd("hello") // expected-error{{no member named 'fnd' in 'class std::basic_string<char>'; did you mean 'find'?}}
35 == std::string::pos; // expected-error{{no member named 'pos' in 'class std::basic_string<char>'; did you mean 'npos'?}}
Douglas Gregor598b08f2009-12-31 05:20:13 +000036}
Douglas Gregor15e77a22009-12-31 09:10:24 +000037
38struct Base { };
Douglas Gregor43a08572010-01-07 00:26:25 +000039struct Derived : public Base { // expected-note{{base class 'struct Base' specified here}}
Douglas Gregor6da83622010-01-07 00:17:44 +000040 int member; // expected-note 3{{'member' declared here}}
Douglas Gregor15e77a22009-12-31 09:10:24 +000041
42 Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}
43 ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}}
Douglas Gregor4f248632010-01-01 17:44:25 +000044
45 int getMember() const {
46 return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
47 }
48
49 int &getMember();
Douglas Gregor15e77a22009-12-31 09:10:24 +000050};
Douglas Gregor4f248632010-01-01 17:44:25 +000051
52int &Derived::getMember() {
53 return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
54}