summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/member-expr.cpp
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2013-07-31 17:38:24 +0000
committerKaelyn Uhrain <rikka@google.com>2013-07-31 17:38:24 +0000
commit0c51de4ab1ae11f105c0c9bf7f7deb603b3a67e2 (patch)
tree7e536d555f971077184fc5bcae6053bc9404d1c7 /clang/test/SemaCXX/member-expr.cpp
parent374089e7b888f97fe45c0f128a10ec261d5fd301 (diff)
downloadbcm5719-llvm-0c51de4ab1ae11f105c0c9bf7f7deb603b3a67e2.tar.gz
bcm5719-llvm-0c51de4ab1ae11f105c0c9bf7f7deb603b3a67e2.zip
Improve the diagnostic experience, including adding recovery, for
changing '->' to '.' when there is no operator-> defined for a class. llvm-svn: 187504
Diffstat (limited to 'clang/test/SemaCXX/member-expr.cpp')
-rw-r--r--clang/test/SemaCXX/member-expr.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/clang/test/SemaCXX/member-expr.cpp b/clang/test/SemaCXX/member-expr.cpp
index 338894c92a4..e2462aa48d6 100644
--- a/clang/test/SemaCXX/member-expr.cpp
+++ b/clang/test/SemaCXX/member-expr.cpp
@@ -79,16 +79,13 @@ namespace test5 {
};
void test0(int x) {
- x.A::foo<int>(); // expected-error {{'int' is not a structure or union}}
}
void test1(A *x) {
- x.A::foo<int>(); // expected-error {{'test5::A *' is a pointer}}
}
void test2(A &x) {
- x->A::foo<int>(); // expected-error {{'test5::A' is not a pointer}} \
- // expected-note {{did you mean to use '.' instead?}}
+ x->A::foo<int>(); // expected-error {{'test5::A' is not a pointer; maybe you meant to use '.'?}}
}
}
@@ -182,7 +179,36 @@ namespace PR15045 {
int f() {
Cl0 c;
- return c->a; // expected-error {{member reference type 'PR15045::Cl0' is not a pointer}} \
- // expected-note {{did you mean to use '.' instead?}}
+ return c->a; // expected-error {{member reference type 'PR15045::Cl0' is not a pointer; maybe you meant to use '.'?}}
+ }
+
+ struct bar {
+ void func(); // expected-note {{'func' declared here}}
+ };
+
+ struct foo {
+ bar operator->(); // expected-note 2 {{'->' applied to return value of the operator->() declared here}}
+ };
+
+ template <class T> void call_func(T t) {
+ t->func(); // expected-error-re 2 {{member reference type 'PR15045::bar' is not a pointer$}} \
+ // expected-note {{did you mean to use '.' instead?}}
+ }
+
+ void test_arrow_on_non_pointer_records() {
+ bar e;
+ foo f;
+
+ // Show that recovery has happened by also triggering typo correction
+ e->Func(); // expected-error {{member reference type 'PR15045::bar' is not a pointer; maybe you meant to use '.'?}} \
+ // expected-error {{no member named 'Func' in 'PR15045::bar'; did you mean 'func'?}}
+
+ // Make sure a fixit isn't given in the case that the '->' isn't actually
+ // the problem (the problem is with the return value of an operator->).
+ f->func(); // expected-error-re {{member reference type 'PR15045::bar' is not a pointer$}}
+
+ call_func(e); // expected-note {{in instantiation of function template specialization 'PR15045::call_func<PR15045::bar>' requested here}}
+
+ call_func(f); // expected-note {{in instantiation of function template specialization 'PR15045::call_func<PR15045::foo>' requested here}}
}
}
OpenPOWER on IntegriCloud