blob: dc6789fa86182eab8fbf74f01fc692ca84167998 [file] [log] [blame]
Douglas Gregor546be3c2009-12-30 17:04:44 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor736fc1b2010-01-01 17:23:17 +00002// RUN: %clang_cc1 -fsyntax-only -fixit -o - %s | %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ -
Douglas Gregor546be3c2009-12-30 17:04:44 +00003namespace std {
Douglas Gregor67dd1d42010-01-07 00:17:44 +00004 template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}}
John McCall7002f4c2010-04-09 19:03:51 +00005 public:
Douglas Gregor67dd1d42010-01-07 00:17:44 +00006 int find(const char *substr); // expected-note{{'find' declared here}}
7 static const int npos = -1; // expected-note{{'npos' declared here}}
Douglas Gregorbb092ba2009-12-31 05:20:13 +00008 };
9
Douglas Gregor67dd1d42010-01-07 00:17:44 +000010 typedef basic_string<char> string; // expected-note 2{{'string' declared here}}
Douglas Gregor546be3c2009-12-30 17:04:44 +000011}
12
Douglas Gregor67dd1d42010-01-07 00:17:44 +000013namespace otherstd { // expected-note 2{{'otherstd' declared here}}
Douglas Gregor546be3c2009-12-30 17:04:44 +000014 using namespace std;
15}
16
17using namespace std;
18
Douglas Gregor175a6562009-12-31 08:26:35 +000019other_std::strng str1; // expected-error{{use of undeclared identifier 'other_std'; did you mean 'otherstd'?}} \
20// expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
Douglas Gregor546be3c2009-12-30 17:04:44 +000021tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
Douglas Gregorbb092ba2009-12-31 05:20:13 +000022
Douglas Gregor6c409a02009-12-31 08:27:32 +000023::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
24
Douglas Gregor539c5c32010-01-07 00:31:29 +000025float area(float radius, // expected-note{{'radius' declared here}}
26 float pi) {
27 return radious * pi; // expected-error{{did you mean 'radius'?}}
Douglas Gregorbb092ba2009-12-31 05:20:13 +000028}
29
30bool test_string(std::string s) {
Douglas Gregorbfea2392009-12-31 08:11:17 +000031 basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}}
32 std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}}
33 (void)b1;
34 (void)b2;
John McCall7c2342d2010-03-10 11:27:22 +000035 return s.fnd("hello") // expected-error{{no member named 'fnd' in 'std::basic_string<char>'; did you mean 'find'?}}
36 == std::string::pos; // expected-error{{no member named 'pos' in 'std::basic_string<char>'; did you mean 'npos'?}}
Douglas Gregorbb092ba2009-12-31 05:20:13 +000037}
Douglas Gregorfe0241e2009-12-31 09:10:24 +000038
39struct Base { };
John McCall7c2342d2010-03-10 11:27:22 +000040struct Derived : public Base { // expected-note{{base class 'Base' specified here}}
Douglas Gregor67dd1d42010-01-07 00:17:44 +000041 int member; // expected-note 3{{'member' declared here}}
Douglas Gregorfe0241e2009-12-31 09:10:24 +000042
43 Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}
44 ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}}
Douglas Gregore3582012010-01-01 17:44:25 +000045
46 int getMember() const {
47 return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
48 }
49
50 int &getMember();
Douglas Gregorfe0241e2009-12-31 09:10:24 +000051};
Douglas Gregore3582012010-01-01 17:44:25 +000052
53int &Derived::getMember() {
54 return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
55}