Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 2 | // 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 Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 5 | namespace std { |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 6 | template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}} |
John McCall | 7002f4c | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 7 | public: |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 8 | int find(const char *substr); // expected-note{{'find' declared here}} |
| 9 | static const int npos = -1; // expected-note{{'npos' declared here}} |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 10 | }; |
| 11 | |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 12 | typedef basic_string<char> string; // expected-note 2{{'string' declared here}} |
Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 13 | } |
| 14 | |
Douglas Gregor | 6699220 | 2010-06-29 17:53:46 +0000 | [diff] [blame] | 15 | namespace otherstd { // expected-note 2{{'otherstd' declared here}} \ |
Douglas Gregor | ed84076 | 2010-06-29 19:17:14 +0000 | [diff] [blame] | 16 | // expected-note{{namespace 'otherstd' defined here}} |
Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 17 | using namespace std; |
| 18 | } |
| 19 | |
| 20 | using namespace std; |
| 21 | |
Douglas Gregor | 175a656 | 2009-12-31 08:26:35 +0000 | [diff] [blame] | 22 | other_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 Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 24 | tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}} |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 25 | |
Douglas Gregor | 6c409a0 | 2009-12-31 08:27:32 +0000 | [diff] [blame] | 26 | ::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}} |
| 27 | |
Douglas Gregor | 539c5c3 | 2010-01-07 00:31:29 +0000 | [diff] [blame] | 28 | float area(float radius, // expected-note{{'radius' declared here}} |
| 29 | float pi) { |
| 30 | return radious * pi; // expected-error{{did you mean 'radius'?}} |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 31 | } |
| 32 | |
Douglas Gregor | 6699220 | 2010-06-29 17:53:46 +0000 | [diff] [blame] | 33 | using namespace othestd; // expected-error{{no namespace named 'othestd'; did you mean 'otherstd'?}} |
Douglas Gregor | ed84076 | 2010-06-29 19:17:14 +0000 | [diff] [blame] | 34 | namespace blargh = otherstd; // expected-note 3{{namespace 'blargh' defined here}} |
Douglas Gregor | 6699220 | 2010-06-29 17:53:46 +0000 | [diff] [blame] | 35 | using namespace ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}} |
| 36 | |
Douglas Gregor | 0e8c4b9 | 2010-06-29 18:55:19 +0000 | [diff] [blame] | 37 | namespace wibble = blarg; // expected-error{{no namespace named 'blarg'; did you mean 'blargh'?}} |
| 38 | namespace wobble = ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}} |
| 39 | |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 40 | bool test_string(std::string s) { |
Douglas Gregor | bfea239 | 2009-12-31 08:11:17 +0000 | [diff] [blame] | 41 | basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}} |
| 42 | std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}} |
| 43 | (void)b1; |
| 44 | (void)b2; |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 45 | return s.fnd("hello") // expected-error{{no member named 'fnd' in 'std::basic_string<char>'; did you mean 'find'?}} |
| 46 | == std::string::pos; // expected-error{{no member named 'pos' in 'std::basic_string<char>'; did you mean 'npos'?}} |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 47 | } |
Douglas Gregor | fe0241e | 2009-12-31 09:10:24 +0000 | [diff] [blame] | 48 | |
| 49 | struct Base { }; |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 50 | struct Derived : public Base { // expected-note{{base class 'Base' specified here}} |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 51 | int member; // expected-note 3{{'member' declared here}} |
Douglas Gregor | fe0241e | 2009-12-31 09:10:24 +0000 | [diff] [blame] | 52 | |
| 53 | Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}} |
| 54 | ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}} |
Douglas Gregor | e358201 | 2010-01-01 17:44:25 +0000 | [diff] [blame] | 55 | |
| 56 | int getMember() const { |
| 57 | return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}} |
| 58 | } |
| 59 | |
| 60 | int &getMember(); |
Douglas Gregor | fe0241e | 2009-12-31 09:10:24 +0000 | [diff] [blame] | 61 | }; |
Douglas Gregor | e358201 | 2010-01-01 17:44:25 +0000 | [diff] [blame] | 62 | |
| 63 | int &Derived::getMember() { |
| 64 | return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}} |
| 65 | } |