1546be3c5c000626c8cdf65e32e8ed9b90c424eddDouglas Gregor// RUN: %clang_cc1 -fsyntax-only -verify %s
2ba5f6eced29937e4e4851a2c0980744768413d66Nick Lewycky// RUN: cp %s %t
327766d2501259c7b12b1056e0c491a927b304e10Douglas Gregor// RUN: not %clang_cc1 -fsyntax-only -fixit -x c++ %t
4ba5f6eced29937e4e4851a2c0980744768413d66Nick Lewycky// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t
527766d2501259c7b12b1056e0c491a927b304e10Douglas Gregor// RUN: grep test_string %t
69a632eaa0ee73e4db701a8df74e92909d1fa350eDouglas Gregor
7546be3c5c000626c8cdf65e32e8ed9b90c424eddDouglas Gregornamespace std {
867dd1d4df1b28973e12e0981129b2517d2033b66Douglas Gregor  template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}}
97002f4c03c2d0544f4e8bea8d3a5636519081e35John McCall  public:
1067dd1d4df1b28973e12e0981129b2517d2033b66Douglas Gregor    int find(const char *substr); // expected-note{{'find' declared here}}
1167dd1d4df1b28973e12e0981129b2517d2033b66Douglas Gregor    static const int npos = -1; // expected-note{{'npos' declared here}}
12bb092bafa984e9fa05136b5cef40fd4374dea0f6Douglas Gregor  };
13bb092bafa984e9fa05136b5cef40fd4374dea0f6Douglas Gregor
1467dd1d4df1b28973e12e0981129b2517d2033b66Douglas Gregor  typedef basic_string<char> string; // expected-note 2{{'string' declared here}}
15546be3c5c000626c8cdf65e32e8ed9b90c424eddDouglas Gregor}
16546be3c5c000626c8cdf65e32e8ed9b90c424eddDouglas Gregor
176699220f73f11e471b5e5aa42eaf064afeaa079eDouglas Gregornamespace otherstd { // expected-note 2{{'otherstd' declared here}} \
18ed8407692d47833abddd31a8cf30bf560e771c9bDouglas Gregor                     // expected-note{{namespace 'otherstd' defined here}}
19546be3c5c000626c8cdf65e32e8ed9b90c424eddDouglas Gregor  using namespace std;
20546be3c5c000626c8cdf65e32e8ed9b90c424eddDouglas Gregor}
21546be3c5c000626c8cdf65e32e8ed9b90c424eddDouglas Gregor
22546be3c5c000626c8cdf65e32e8ed9b90c424eddDouglas Gregorusing namespace std;
23546be3c5c000626c8cdf65e32e8ed9b90c424eddDouglas Gregor
24175a65686eba7c7a9cb02412136fddd2d2c56dd7Douglas Gregorother_std::strng str1; // expected-error{{use of undeclared identifier 'other_std'; did you mean 'otherstd'?}} \
25175a65686eba7c7a9cb02412136fddd2d2c56dd7Douglas Gregor// expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
26546be3c5c000626c8cdf65e32e8ed9b90c424eddDouglas Gregortring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
27bb092bafa984e9fa05136b5cef40fd4374dea0f6Douglas Gregor
286c409a031946c069b7f8c33e7d71175563028afbDouglas Gregor::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
296c409a031946c069b7f8c33e7d71175563028afbDouglas Gregor
30539c5c34063066753f27bb0f39fdcde1acc06328Douglas Gregorfloat area(float radius, // expected-note{{'radius' declared here}}
31539c5c34063066753f27bb0f39fdcde1acc06328Douglas Gregor           float pi) {
32539c5c34063066753f27bb0f39fdcde1acc06328Douglas Gregor  return radious * pi; // expected-error{{did you mean 'radius'?}}
33bb092bafa984e9fa05136b5cef40fd4374dea0f6Douglas Gregor}
34bb092bafa984e9fa05136b5cef40fd4374dea0f6Douglas Gregor
356699220f73f11e471b5e5aa42eaf064afeaa079eDouglas Gregorusing namespace othestd; // expected-error{{no namespace named 'othestd'; did you mean 'otherstd'?}}
36ed8407692d47833abddd31a8cf30bf560e771c9bDouglas Gregornamespace blargh = otherstd; // expected-note 3{{namespace 'blargh' defined here}}
376699220f73f11e471b5e5aa42eaf064afeaa079eDouglas Gregorusing namespace ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
386699220f73f11e471b5e5aa42eaf064afeaa079eDouglas Gregor
390e8c4b9fac447c6c9849e3ef8beb1ef273ac0f97Douglas Gregornamespace wibble = blarg; // expected-error{{no namespace named 'blarg'; did you mean 'blargh'?}}
400e8c4b9fac447c6c9849e3ef8beb1ef273ac0f97Douglas Gregornamespace wobble = ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
410e8c4b9fac447c6c9849e3ef8beb1ef273ac0f97Douglas Gregor
42bb092bafa984e9fa05136b5cef40fd4374dea0f6Douglas Gregorbool test_string(std::string s) {
43bfea239cafdb13256982eb891b151c5c07c1e7a9Douglas Gregor  basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}}
44bfea239cafdb13256982eb891b151c5c07c1e7a9Douglas Gregor  std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}}
45bfea239cafdb13256982eb891b151c5c07c1e7a9Douglas Gregor  (void)b1;
46bfea239cafdb13256982eb891b151c5c07c1e7a9Douglas Gregor  (void)b2;
477c2342dd4c9947806842e5aca3d2bb2e542853c9John McCall  return s.fnd("hello") // expected-error{{no member named 'fnd' in 'std::basic_string<char>'; did you mean 'find'?}}
487c2342dd4c9947806842e5aca3d2bb2e542853c9John McCall    == std::string::pos; // expected-error{{no member named 'pos' in 'std::basic_string<char>'; did you mean 'npos'?}}
49bb092bafa984e9fa05136b5cef40fd4374dea0f6Douglas Gregor}
50fe0241e31dd2d1af60116adf6f71dedc88cd1f68Douglas Gregor
51fe0241e31dd2d1af60116adf6f71dedc88cd1f68Douglas Gregorstruct Base { };
527c2342dd4c9947806842e5aca3d2bb2e542853c9John McCallstruct Derived : public Base { // expected-note{{base class 'Base' specified here}}
5367dd1d4df1b28973e12e0981129b2517d2033b66Douglas Gregor  int member; // expected-note 3{{'member' declared here}}
54fe0241e31dd2d1af60116adf6f71dedc88cd1f68Douglas Gregor
55fe0241e31dd2d1af60116adf6f71dedc88cd1f68Douglas Gregor  Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}
56fe0241e31dd2d1af60116adf6f71dedc88cd1f68Douglas Gregor              ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}}
57e3582011a63a78cdfa0917077ed87ccb9b3a87b5Douglas Gregor
58e3582011a63a78cdfa0917077ed87ccb9b3a87b5Douglas Gregor  int getMember() const {
59e3582011a63a78cdfa0917077ed87ccb9b3a87b5Douglas Gregor    return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
60e3582011a63a78cdfa0917077ed87ccb9b3a87b5Douglas Gregor  }
61e3582011a63a78cdfa0917077ed87ccb9b3a87b5Douglas Gregor
62e3582011a63a78cdfa0917077ed87ccb9b3a87b5Douglas Gregor  int &getMember();
63fe0241e31dd2d1af60116adf6f71dedc88cd1f68Douglas Gregor};
64e3582011a63a78cdfa0917077ed87ccb9b3a87b5Douglas Gregor
65e3582011a63a78cdfa0917077ed87ccb9b3a87b5Douglas Gregorint &Derived::getMember() {
66e3582011a63a78cdfa0917077ed87ccb9b3a87b5Douglas Gregor  return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
67e3582011a63a78cdfa0917077ed87ccb9b3a87b5Douglas Gregor}
683b887354b1b667c97d070ddc67b5354353c4c07bDouglas Gregor
693b887354b1b667c97d070ddc67b5354353c4c07bDouglas Gregortypedef int Integer; // expected-note{{'Integer' declared here}}
703b887354b1b667c97d070ddc67b5354353c4c07bDouglas Gregorint global_value; // expected-note{{'global_value' declared here}}
713b887354b1b667c97d070ddc67b5354353c4c07bDouglas Gregor
723b887354b1b667c97d070ddc67b5354353c4c07bDouglas Gregorint foo() {
733b887354b1b667c97d070ddc67b5354353c4c07bDouglas Gregor  integer * i = 0; // expected-error{{unknown type name 'integer'; did you mean 'Integer'?}}
743b887354b1b667c97d070ddc67b5354353c4c07bDouglas Gregor  unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
753b887354b1b667c97d070ddc67b5354353c4c07bDouglas Gregor  return *i + *ptr + global_val; // expected-error{{use of undeclared identifier 'global_val'; did you mean 'global_value'?}}
763b887354b1b667c97d070ddc67b5354353c4c07bDouglas Gregor}
77d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor
78d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregornamespace nonstd {
79d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor  typedef std::basic_string<char> yarn; // expected-note{{'nonstd::yarn' declared here}}
80d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor}
81d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor
82d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregoryarn str4; // expected-error{{unknown type name 'yarn'; did you mean 'nonstd::yarn'?}}
8307f4a06c402a2ccdd9eae7a3d710990b22040001Douglas Gregor
8407f4a06c402a2ccdd9eae7a3d710990b22040001Douglas Gregornamespace check_bool {
8507f4a06c402a2ccdd9eae7a3d710990b22040001Douglas Gregor  void f() {
8607f4a06c402a2ccdd9eae7a3d710990b22040001Douglas Gregor    Bool b; // expected-error{{use of undeclared identifier 'Bool'; did you mean 'bool'?}}
8707f4a06c402a2ccdd9eae7a3d710990b22040001Douglas Gregor  }
8807f4a06c402a2ccdd9eae7a3d710990b22040001Douglas Gregor}
89