summaryrefslogtreecommitdiffstats
path: root/clang/test/FixIt/typo.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2012-10-12 20:00:44 +0000
committerDavid Blaikie <dblaikie@gmail.com>2012-10-12 20:00:44 +0000
commit04ea41c39a65b17fe8e5c4f8ba4caa9f3841f9cf (patch)
treeffa9d11355aa11f1cbb129f01934b91feca007af /clang/test/FixIt/typo.cpp
parent84d3779819c3b7278d85d76c33f9ca8cf9a4facc (diff)
downloadbcm5719-llvm-04ea41c39a65b17fe8e5c4f8ba4caa9f3841f9cf.tar.gz
bcm5719-llvm-04ea41c39a65b17fe8e5c4f8ba4caa9f3841f9cf.zip
Fix typo correction of one qualified name to another.
When suggesting "foo::bar" as a correction for "fob::bar" we mistakenly replaced only "bar" with "foo::bar" producing "fob::foo::bar" which was broken. This corrects that replacement in as many places as I could find & provides test cases for all those cases I could find a test case for. There are a couple that don't seem to be reachable (one looks entirely dead, the other just doesn't seem to ever get called with a namespace to namespace change). Review by Richard Smith ( http://llvm-reviews.chandlerc.com/D57 ). llvm-svn: 165817
Diffstat (limited to 'clang/test/FixIt/typo.cpp')
-rw-r--r--clang/test/FixIt/typo.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/clang/test/FixIt/typo.cpp b/clang/test/FixIt/typo.cpp
index 3d40da8d256..b3568a5bbf7 100644
--- a/clang/test/FixIt/typo.cpp
+++ b/clang/test/FixIt/typo.cpp
@@ -5,7 +5,8 @@
// RUN: grep test_string %t
namespace std {
- template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}}
+ template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}} \
+ // expected-note {{'otherstd::basic_string' declared here}}
public:
int find(const char *substr); // expected-note{{'find' declared here}}
static const int npos = -1; // expected-note{{'npos' declared here}}
@@ -76,13 +77,50 @@ int foo() {
}
namespace nonstd {
- typedef std::basic_string<char> yarn; // expected-note{{'nonstd::yarn' declared here}}
+ typedef std::basic_string<char> yarn; // expected-note 2 {{'nonstd::yarn' declared here}}
+ int narf; // expected-note{{'nonstd::narf' declared here}}
}
yarn str4; // expected-error{{unknown type name 'yarn'; did you mean 'nonstd::yarn'?}}
+wibble::yarn str5; // expected-error{{no type named 'yarn' in namespace 'otherstd'; did you mean 'nonstd::yarn'?}}
+
+int poit() {
+ nonstd::basic_string<char> str; // expected-error{{no template named 'basic_string' in namespace 'nonstd'; did you mean 'otherstd::basic_string'?}}
+ return wibble::narf; // expected-error{{no member named 'narf' in namespace 'otherstd'; did you mean 'nonstd::narf'?}}
+}
namespace check_bool {
void f() {
Bool b; // expected-error{{use of undeclared identifier 'Bool'; did you mean 'bool'?}}
}
}
+
+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;
+}
OpenPOWER on IntegriCloud