2009-12-31 01:04:44 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2010-04-24 09:30:46 +08:00
|
|
|
// RUN: cp %s %t
|
2011-04-27 11:47:06 +08:00
|
|
|
// RUN: not %clang_cc1 -fsyntax-only -fixit -x c++ %t
|
2010-04-24 09:30:46 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t
|
2011-04-27 11:47:06 +08:00
|
|
|
// RUN: grep test_string %t
|
2010-10-20 11:06:34 +08:00
|
|
|
|
2009-12-31 01:04:44 +08:00
|
|
|
namespace std {
|
2013-07-03 07:47:44 +08:00
|
|
|
template<typename T> class basic_string { // expected-note 3{{'basic_string' declared here}}
|
2010-04-10 03:03:51 +08:00
|
|
|
public:
|
2010-01-07 08:17:44 +08:00
|
|
|
int find(const char *substr); // expected-note{{'find' declared here}}
|
|
|
|
static const int npos = -1; // expected-note{{'npos' declared here}}
|
2009-12-31 13:20:13 +08:00
|
|
|
};
|
|
|
|
|
2010-01-07 08:17:44 +08:00
|
|
|
typedef basic_string<char> string; // expected-note 2{{'string' declared here}}
|
2009-12-31 01:04:44 +08:00
|
|
|
}
|
|
|
|
|
2010-06-30 01:53:46 +08:00
|
|
|
namespace otherstd { // expected-note 2{{'otherstd' declared here}} \
|
2010-06-30 03:17:14 +08:00
|
|
|
// expected-note{{namespace 'otherstd' defined here}}
|
2009-12-31 01:04:44 +08:00
|
|
|
using namespace std;
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2009-12-31 16:26:35 +08:00
|
|
|
other_std::strng str1; // expected-error{{use of undeclared identifier 'other_std'; did you mean 'otherstd'?}} \
|
|
|
|
// expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
|
2009-12-31 01:04:44 +08:00
|
|
|
tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
|
2009-12-31 13:20:13 +08:00
|
|
|
|
2009-12-31 16:27:32 +08:00
|
|
|
::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
|
|
|
|
|
2010-01-07 08:31:29 +08:00
|
|
|
float area(float radius, // expected-note{{'radius' declared here}}
|
|
|
|
float pi) {
|
|
|
|
return radious * pi; // expected-error{{did you mean 'radius'?}}
|
2009-12-31 13:20:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-30 01:53:46 +08:00
|
|
|
using namespace othestd; // expected-error{{no namespace named 'othestd'; did you mean 'otherstd'?}}
|
2010-06-30 03:17:14 +08:00
|
|
|
namespace blargh = otherstd; // expected-note 3{{namespace 'blargh' defined here}}
|
2010-06-30 01:53:46 +08:00
|
|
|
using namespace ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
|
|
|
|
|
2010-06-30 02:55:19 +08:00
|
|
|
namespace wibble = blarg; // expected-error{{no namespace named 'blarg'; did you mean 'blargh'?}}
|
|
|
|
namespace wobble = ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
|
|
|
|
|
2009-12-31 13:20:13 +08:00
|
|
|
bool test_string(std::string s) {
|
2009-12-31 16:11:17 +08:00
|
|
|
basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}}
|
|
|
|
std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}}
|
|
|
|
(void)b1;
|
|
|
|
(void)b2;
|
2010-03-10 19:27:22 +08:00
|
|
|
return s.fnd("hello") // expected-error{{no member named 'fnd' in 'std::basic_string<char>'; did you mean 'find'?}}
|
|
|
|
== std::string::pos; // expected-error{{no member named 'pos' in 'std::basic_string<char>'; did you mean 'npos'?}}
|
2009-12-31 13:20:13 +08:00
|
|
|
}
|
2009-12-31 17:10:24 +08:00
|
|
|
|
|
|
|
struct Base { };
|
2010-03-10 19:27:22 +08:00
|
|
|
struct Derived : public Base { // expected-note{{base class 'Base' specified here}}
|
2010-01-07 08:17:44 +08:00
|
|
|
int member; // expected-note 3{{'member' declared here}}
|
2009-12-31 17:10:24 +08:00
|
|
|
|
|
|
|
Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}
|
|
|
|
ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}}
|
2010-01-02 01:44:25 +08:00
|
|
|
|
|
|
|
int getMember() const {
|
|
|
|
return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
|
|
|
|
}
|
|
|
|
|
|
|
|
int &getMember();
|
2009-12-31 17:10:24 +08:00
|
|
|
};
|
2010-01-02 01:44:25 +08:00
|
|
|
|
|
|
|
int &Derived::getMember() {
|
|
|
|
return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
|
|
|
|
}
|
2011-04-27 12:48:22 +08:00
|
|
|
|
|
|
|
typedef int Integer; // expected-note{{'Integer' declared here}}
|
|
|
|
int global_value; // expected-note{{'global_value' declared here}}
|
|
|
|
|
|
|
|
int foo() {
|
|
|
|
integer * i = 0; // expected-error{{unknown type name 'integer'; did you mean 'Integer'?}}
|
|
|
|
unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
|
|
|
|
return *i + *ptr + global_val; // expected-error{{use of undeclared identifier 'global_val'; did you mean 'global_value'?}}
|
|
|
|
}
|
2011-06-29 00:20:02 +08:00
|
|
|
|
|
|
|
namespace nonstd {
|
2012-10-13 04:00:44 +08:00
|
|
|
typedef std::basic_string<char> yarn; // expected-note 2 {{'nonstd::yarn' declared here}}
|
|
|
|
int narf; // expected-note{{'nonstd::narf' declared here}}
|
2011-06-29 00:20:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
yarn str4; // expected-error{{unknown type name 'yarn'; did you mean 'nonstd::yarn'?}}
|
2012-10-13 04:00:44 +08:00
|
|
|
wibble::yarn str5; // expected-error{{no type named 'yarn' in namespace 'otherstd'; did you mean 'nonstd::yarn'?}}
|
|
|
|
|
2013-06-25 01:49:03 +08:00
|
|
|
namespace another {
|
|
|
|
template<typename T> class wide_string {}; // expected-note {{'another::wide_string' declared here}}
|
|
|
|
}
|
2012-10-13 04:00:44 +08:00
|
|
|
int poit() {
|
2013-07-03 07:47:44 +08:00
|
|
|
nonstd::basic_string<char> str; // expected-error{{no template named 'basic_string' in namespace 'nonstd'; did you mean simply 'basic_string'?}}
|
2013-06-25 01:49:03 +08:00
|
|
|
nonstd::wide_string<char> str2; // expected-error{{no template named 'wide_string' in namespace 'nonstd'; did you mean 'another::wide_string'?}}
|
2012-10-13 04:00:44 +08:00
|
|
|
return wibble::narf; // expected-error{{no member named 'narf' in namespace 'otherstd'; did you mean 'nonstd::narf'?}}
|
|
|
|
}
|
2011-07-02 05:27:45 +08:00
|
|
|
|
|
|
|
namespace check_bool {
|
|
|
|
void f() {
|
|
|
|
Bool b; // expected-error{{use of undeclared identifier 'Bool'; did you mean 'bool'?}}
|
|
|
|
}
|
|
|
|
}
|
2012-10-13 04:00:44 +08:00
|
|
|
|
|
|
|
namespace outr {
|
|
|
|
}
|
|
|
|
namespace outer {
|
|
|
|
namespace inner { // expected-note{{'outer::inner' declared here}} \
|
|
|
|
// expected-note{{namespace 'outer::inner' defined here}} \
|
|
|
|
// expected-note{{'inner' declared here}}
|
|
|
|
int i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace outr::inner; // expected-error{{no namespace named 'inner' in namespace 'outr'; did you mean 'outer::inner'?}}
|
|
|
|
|
|
|
|
void func() {
|
|
|
|
outr::inner::i = 3; // expected-error{{no member named 'inner' in namespace 'outr'; did you mean 'outer::inner'?}}
|
|
|
|
outer::innr::i = 4; // expected-error{{no member named 'innr' in namespace 'outer'; did you mean 'inner'?}}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct base {
|
|
|
|
};
|
|
|
|
struct derived : base {
|
|
|
|
int i;
|
|
|
|
};
|
|
|
|
|
|
|
|
void func2() {
|
|
|
|
derived d;
|
|
|
|
// FIXME: we should offer a fix here. We do if the 'i' is misspelled, but we don't do name qualification changes
|
|
|
|
// to replace base::i with derived::i as we would for other qualified name misspellings.
|
|
|
|
// d.base::i = 3;
|
|
|
|
}
|
2013-07-09 07:13:44 +08:00
|
|
|
|
|
|
|
class A {
|
|
|
|
void bar(int);
|
|
|
|
};
|
|
|
|
void bar(int, int); // expected-note{{'::bar' declared here}}
|
|
|
|
void A::bar(int x) {
|
|
|
|
bar(x, 5); // expected-error{{too many arguments to function call, expected 1, have 2; did you mean '::bar'?}}
|
|
|
|
}
|