blob: 581cd25f9ab2bcd390d9557d66ce49bcd22aa569 [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 Gregorbb092ba2009-12-31 05:20:13 +00004 template<typename T> class basic_string {
5 int find(const char *substr);
6 static const int npos = -1;
7 };
8
Douglas Gregor546be3c2009-12-30 17:04:44 +00009 typedef basic_string<char> string;
10}
11
12namespace otherstd {
13 using namespace std;
14}
15
16using namespace std;
17
Douglas Gregor175a6562009-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 Gregor546be3c2009-12-30 17:04:44 +000020tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
Douglas Gregorbb092ba2009-12-31 05:20:13 +000021
Douglas Gregor6c409a02009-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 Gregorbb092ba2009-12-31 05:20:13 +000024float area(float radius, float pi) {
25 return radious * pi; // expected-error{{use of undeclared identifier 'radious'; did you mean 'radius'?}}
26}
27
28bool test_string(std::string s) {
Douglas Gregorbfea2392009-12-31 08:11:17 +000029 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 Gregor2dcc0112009-12-31 07:42:17 +000033 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 Gregorbb092ba2009-12-31 05:20:13 +000035}
Douglas Gregorfe0241e2009-12-31 09:10:24 +000036
37struct Base { };
38struct 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};