blob: 35666efe47529bb565a46dc74012c394503f363c [file] [log] [blame]
Douglas Gregor546be3c2009-12-30 17:04:44 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +00002// 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
Douglas Gregor06ff47b2010-10-20 01:46:04 +00005//
6// FIXME: Disabled while we investigate failure.
7// REQUIRES: disabled
Douglas Gregor546be3c2009-12-30 17:04:44 +00008namespace std {
Douglas Gregor67dd1d42010-01-07 00:17:44 +00009 template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}}
John McCall7002f4c2010-04-09 19:03:51 +000010 public:
Douglas Gregor67dd1d42010-01-07 00:17:44 +000011 int find(const char *substr); // expected-note{{'find' declared here}}
12 static const int npos = -1; // expected-note{{'npos' declared here}}
Douglas Gregorbb092ba2009-12-31 05:20:13 +000013 };
14
Douglas Gregor67dd1d42010-01-07 00:17:44 +000015 typedef basic_string<char> string; // expected-note 2{{'string' declared here}}
Douglas Gregor546be3c2009-12-30 17:04:44 +000016}
17
Douglas Gregor66992202010-06-29 17:53:46 +000018namespace otherstd { // expected-note 2{{'otherstd' declared here}} \
Douglas Gregored840762010-06-29 19:17:14 +000019 // expected-note{{namespace 'otherstd' defined here}}
Douglas Gregor546be3c2009-12-30 17:04:44 +000020 using namespace std;
21}
22
23using namespace std;
24
Douglas Gregor175a6562009-12-31 08:26:35 +000025other_std::strng str1; // expected-error{{use of undeclared identifier 'other_std'; did you mean 'otherstd'?}} \
26// expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
Douglas Gregor546be3c2009-12-30 17:04:44 +000027tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
Douglas Gregorbb092ba2009-12-31 05:20:13 +000028
Douglas Gregor6c409a02009-12-31 08:27:32 +000029::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
30
Douglas Gregor539c5c32010-01-07 00:31:29 +000031float area(float radius, // expected-note{{'radius' declared here}}
32 float pi) {
33 return radious * pi; // expected-error{{did you mean 'radius'?}}
Douglas Gregorbb092ba2009-12-31 05:20:13 +000034}
35
Douglas Gregor66992202010-06-29 17:53:46 +000036using namespace othestd; // expected-error{{no namespace named 'othestd'; did you mean 'otherstd'?}}
Douglas Gregored840762010-06-29 19:17:14 +000037namespace blargh = otherstd; // expected-note 3{{namespace 'blargh' defined here}}
Douglas Gregor66992202010-06-29 17:53:46 +000038using namespace ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
39
Douglas Gregor0e8c4b92010-06-29 18:55:19 +000040namespace wibble = blarg; // expected-error{{no namespace named 'blarg'; did you mean 'blargh'?}}
41namespace wobble = ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
42
Douglas Gregorbb092ba2009-12-31 05:20:13 +000043bool test_string(std::string s) {
Douglas Gregorbfea2392009-12-31 08:11:17 +000044 basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}}
45 std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}}
46 (void)b1;
47 (void)b2;
John McCall7c2342d2010-03-10 11:27:22 +000048 return s.fnd("hello") // expected-error{{no member named 'fnd' in 'std::basic_string<char>'; did you mean 'find'?}}
49 == std::string::pos; // expected-error{{no member named 'pos' in 'std::basic_string<char>'; did you mean 'npos'?}}
Douglas Gregorbb092ba2009-12-31 05:20:13 +000050}
Douglas Gregorfe0241e2009-12-31 09:10:24 +000051
52struct Base { };
John McCall7c2342d2010-03-10 11:27:22 +000053struct Derived : public Base { // expected-note{{base class 'Base' specified here}}
Douglas Gregor67dd1d42010-01-07 00:17:44 +000054 int member; // expected-note 3{{'member' declared here}}
Douglas Gregorfe0241e2009-12-31 09:10:24 +000055
56 Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}
57 ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}}
Douglas Gregore3582012010-01-01 17:44:25 +000058
59 int getMember() const {
60 return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
61 }
62
63 int &getMember();
Douglas Gregorfe0241e2009-12-31 09:10:24 +000064};
Douglas Gregore3582012010-01-01 17:44:25 +000065
66int &Derived::getMember() {
67 return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
68}