diff options
| author | Douglas Gregor <dgregor@apple.com> | 2008-12-22 05:46:06 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2008-12-22 05:46:06 +0000 |
| commit | 97fd6e24c4e094ee6b8ec6d4c1452a5b2595ee62 (patch) | |
| tree | 89c12cbf1385609ff1b9e08ac2b7fb7e9625e46e /clang/test/SemaCXX/overload-member-call.cpp | |
| parent | 25b16dbcd80cb285e76c0bf846dd1538d3b10d96 (diff) | |
| download | bcm5719-llvm-97fd6e24c4e094ee6b8ec6d4c1452a5b2595ee62.tar.gz bcm5719-llvm-97fd6e24c4e094ee6b8ec6d4c1452a5b2595ee62.zip | |
Add support for calls to overloaded member functions. Things to note:
- Overloading has to cope with having both static and non-static
member functions in the overload set.
- The call may or may not have an implicit object argument,
depending on the syntax (x.f() vs. f()) and the context (static
vs. non-static member function).
- We now generate MemberExprs for implicit member access expression.
- We now cope with mutable whenever we're building MemberExprs.
llvm-svn: 61329
Diffstat (limited to 'clang/test/SemaCXX/overload-member-call.cpp')
| -rw-r--r-- | clang/test/SemaCXX/overload-member-call.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/overload-member-call.cpp b/clang/test/SemaCXX/overload-member-call.cpp new file mode 100644 index 00000000000..9c0117f9b14 --- /dev/null +++ b/clang/test/SemaCXX/overload-member-call.cpp @@ -0,0 +1,39 @@ +// RUN: clang -fsyntax-only -verify %s + +struct X { + int& f(int) const; // expected-note{{candidate function}} + float& f(int); // expected-note{{candidate function}} + + void test_f(int x) const { + int& i = f(x); + } + + void test_f2(int x) { + float& f2 = f(x); + } + + int& g(int) const; // expected-note{{candidate function}} + float& g(int); // expected-note{{candidate function}} + static double& g(double); // expected-note{{candidate function}} + + void h(int); +}; + +void test(X x, const X xc, X* xp, const X* xcp, volatile X xv, volatile X* xvp) { + int& i1 = xc.f(0); + int& i2 = xcp->f(0); + float& f1 = x.f(0); + float& f2 = xp->f(0); + xv.f(0); // expected-error{{no matching member function for call to 'f'; candidates are:}} + xvp->f(0); // expected-error{{no matching member function for call to 'f'; candidates are:}} + + int& i3 = xc.g(0); + int& i4 = xcp->g(0); + float& f3 = x.g(0); + float& f4 = xp->g(0); + double& d1 = xp->g(0.0); + double& d2 = X::g(0.0); + X::g(0); // expected-error{{call to 'g' is ambiguous; candidates are:}} + + X::h(0); // expected-error{{call to non-static member function without an object argument}} +} |

