Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 736fc1b | 2010-01-01 17:23:17 +0000 | [diff] [blame^] | 2 | // RUN: %clang_cc1 -fsyntax-only -fixit -o - %s | %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ - |
Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 3 | namespace std { |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 4 | template<typename T> class basic_string { |
| 5 | int find(const char *substr); |
| 6 | static const int npos = -1; |
| 7 | }; |
| 8 | |
Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 9 | typedef basic_string<char> string; |
| 10 | } |
| 11 | |
| 12 | namespace otherstd { |
| 13 | using namespace std; |
| 14 | } |
| 15 | |
| 16 | using namespace std; |
| 17 | |
Douglas Gregor | 175a656 | 2009-12-31 08:26:35 +0000 | [diff] [blame] | 18 | other_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 Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 20 | tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}} |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 21 | |
Douglas Gregor | 6c409a0 | 2009-12-31 08:27:32 +0000 | [diff] [blame] | 22 | ::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}} |
| 23 | |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 24 | float area(float radius, float pi) { |
| 25 | return radious * pi; // expected-error{{use of undeclared identifier 'radious'; did you mean 'radius'?}} |
| 26 | } |
| 27 | |
| 28 | bool test_string(std::string s) { |
Douglas Gregor | bfea239 | 2009-12-31 08:11:17 +0000 | [diff] [blame] | 29 | basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}} |
| 30 | std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}} |
| 31 | (void)b1; |
| 32 | (void)b2; |
Douglas Gregor | 2dcc011 | 2009-12-31 07:42:17 +0000 | [diff] [blame] | 33 | return s.fnd("hello") // expected-error{{no member named 'fnd' in 'class std::basic_string<char>'; did you mean 'find'?}} |
| 34 | == std::string::pos; // expected-error{{no member named 'pos' in 'class std::basic_string<char>'; did you mean 'npos'?}} |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 35 | } |
Douglas Gregor | fe0241e | 2009-12-31 09:10:24 +0000 | [diff] [blame] | 36 | |
| 37 | struct Base { }; |
| 38 | struct Derived : public Base { |
| 39 | int member; |
| 40 | |
| 41 | Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}} |
| 42 | ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}} |
| 43 | }; |