blob: 9789a5807a6926e59777d17b2ec827b1677a796b [file] [log] [blame]
Douglas Gregor2d435302009-12-30 17:04:44 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Nick Lewycky784fad72010-04-24 01:30:46 +00002// RUN: cp %s %t
3// RUN: %clang_cc1 -fsyntax-only -fixit -x c++ %t || true
4// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t
Douglas Gregor2d435302009-12-30 17:04:44 +00005namespace std {
Douglas Gregor6da83622010-01-07 00:17:44 +00006 template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}}
John McCall3155f572010-04-09 19:03:51 +00007 public:
Douglas Gregor6da83622010-01-07 00:17:44 +00008 int find(const char *substr); // expected-note{{'find' declared here}}
9 static const int npos = -1; // expected-note{{'npos' declared here}}
Douglas Gregor598b08f2009-12-31 05:20:13 +000010 };
11
Douglas Gregor6da83622010-01-07 00:17:44 +000012 typedef basic_string<char> string; // expected-note 2{{'string' declared here}}
Douglas Gregor2d435302009-12-30 17:04:44 +000013}
14
Douglas Gregorcdf87022010-06-29 17:53:46 +000015namespace otherstd { // expected-note 2{{'otherstd' declared here}} \
16 // expected-note{{namespace 'otherstd' defined here}}
Douglas Gregor2d435302009-12-30 17:04:44 +000017 using namespace std;
18}
19
20using namespace std;
21
Douglas Gregor532e68f2009-12-31 08:26:35 +000022other_std::strng str1; // expected-error{{use of undeclared identifier 'other_std'; did you mean 'otherstd'?}} \
23// expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
Douglas Gregor2d435302009-12-30 17:04:44 +000024tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
Douglas Gregor598b08f2009-12-31 05:20:13 +000025
Douglas Gregor103dae42009-12-31 08:27:32 +000026::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
27
Douglas Gregor712dcfe2010-01-07 00:31:29 +000028float area(float radius, // expected-note{{'radius' declared here}}
29 float pi) {
30 return radious * pi; // expected-error{{did you mean 'radius'?}}
Douglas Gregor598b08f2009-12-31 05:20:13 +000031}
32
Douglas Gregorcdf87022010-06-29 17:53:46 +000033using namespace othestd; // expected-error{{no namespace named 'othestd'; did you mean 'otherstd'?}}
34namespace blargh = otherstd; // expected-note{{namespace 'blargh' defined here}}
35using namespace ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
36
Douglas Gregor598b08f2009-12-31 05:20:13 +000037bool test_string(std::string s) {
Douglas Gregorff18cc12009-12-31 08:11:17 +000038 basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}}
39 std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}}
40 (void)b1;
41 (void)b2;
John McCall85f90552010-03-10 11:27:22 +000042 return s.fnd("hello") // expected-error{{no member named 'fnd' in 'std::basic_string<char>'; did you mean 'find'?}}
43 == std::string::pos; // expected-error{{no member named 'pos' in 'std::basic_string<char>'; did you mean 'npos'?}}
Douglas Gregor598b08f2009-12-31 05:20:13 +000044}
Douglas Gregor15e77a22009-12-31 09:10:24 +000045
46struct Base { };
John McCall85f90552010-03-10 11:27:22 +000047struct Derived : public Base { // expected-note{{base class 'Base' specified here}}
Douglas Gregor6da83622010-01-07 00:17:44 +000048 int member; // expected-note 3{{'member' declared here}}
Douglas Gregor15e77a22009-12-31 09:10:24 +000049
50 Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}
51 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 +000052
53 int getMember() const {
54 return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
55 }
56
57 int &getMember();
Douglas Gregor15e77a22009-12-31 09:10:24 +000058};
Douglas Gregor4f248632010-01-01 17:44:25 +000059
60int &Derived::getMember() {
61 return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
62}