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