diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-11-19 17:17:41 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-11-19 17:17:41 +0000 |
commit | 337c6b9f5d502dc1c5acea628bf7bf9e828efc0e (patch) | |
tree | 74b96efaf3032268cc7547d824cced4c93574bb4 /test/SemaCXX/overloaded-operator.cpp | |
parent | 5cb93b8bf009c4b0ae09b71ba85f54b2a7ea8022 (diff) |
Support overloading of the subscript operator[], including support for
built-in operator candidates. Test overloading of '&' and ','.
In C++, a comma expression is an lvalue if its right-hand
subexpression is an lvalue. Update Expr::isLvalue accordingly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/overloaded-operator.cpp')
-rw-r--r-- | test/SemaCXX/overloaded-operator.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp index 2948656818..1eb86bd1aa 100644 --- a/test/SemaCXX/overloaded-operator.cpp +++ b/test/SemaCXX/overloaded-operator.cpp @@ -97,3 +97,27 @@ void test_smartptr(SmartPtr ptr, const SmartPtr cptr) { int &ir = *ptr; // FIXME: reinstate long &lr = *cptr; } + + +struct ArrayLike { + int& operator[](int); +}; + +void test_arraylike(ArrayLike a) { + int& ir = a[17]; +} + +struct SmartRef { + int* operator&(); +}; + +void test_smartref(SmartRef r) { + int* ip = &r; +} + +bool& operator,(X, Y); + +void test_comma(X x, Y y) { + bool& b1 = (x, y); + X& xr = (x, x); +} |