blob: c0570258c53b5b75951729e71ab47f794fb68d22 [file] [log] [blame]
Shih-wei Liaof8fd82b2010-02-10 11:10:31 -08001// RUN: %clang_cc1 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -fsyntax-only -fixit -o - %s | %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ -
3namespace std {
4 template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}}
5 int find(const char *substr); // expected-note{{'find' declared here}}
6 static const int npos = -1; // expected-note{{'npos' declared here}}
7 };
8
9 typedef basic_string<char> string; // expected-note 2{{'string' declared here}}
10}
11
12namespace otherstd { // expected-note 2{{'otherstd' declared here}}
13 using namespace std;
14}
15
16using namespace std;
17
18other_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'?}}
20tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
21
22::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
23
24float area(float radius, // expected-note{{'radius' declared here}}
25 float pi) {
26 return radious * pi; // expected-error{{did you mean 'radius'?}}
27}
28
29bool test_string(std::string s) {
30 basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}}
31 std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}}
32 (void)b1;
33 (void)b2;
34 return s.fnd("hello") // expected-error{{no member named 'fnd' in 'class std::basic_string<char>'; did you mean 'find'?}}
35 == std::string::pos; // expected-error{{no member named 'pos' in 'class std::basic_string<char>'; did you mean 'npos'?}}
36}
37
38struct Base { };
39struct Derived : public Base { // expected-note{{base class 'struct Base' specified here}}
40 int member; // expected-note 3{{'member' declared here}}
41
42 Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}
43 ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}}
44
45 int getMember() const {
46 return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
47 }
48
49 int &getMember();
50};
51
52int &Derived::getMember() {
53 return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
54}