diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-05 19:35:51 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-05 19:35:51 +0000 |
| commit | 91fc7d89d0d5a05e60abac5259fc403d4360e92e (patch) | |
| tree | 53f4287a4b77a3adbc8306ae984eeccfe29f73a6 /clang/test/SemaCXX/overloaded-operator.cpp | |
| parent | 77672776392e36a7bd65cb2845834675aefd8076 (diff) | |
| download | bcm5719-llvm-91fc7d89d0d5a05e60abac5259fc403d4360e92e.tar.gz bcm5719-llvm-91fc7d89d0d5a05e60abac5259fc403d4360e92e.zip | |
Fix two-phase name lookup for non-dependent overloaded operators.
If we resolve an overloaded operator call to a specific function during
template definition, don't perform ADL during template instantiation.
Doing so finds overloads that we're not supposed to find.
llvm-svn: 315005
Diffstat (limited to 'clang/test/SemaCXX/overloaded-operator.cpp')
| -rw-r--r-- | clang/test/SemaCXX/overloaded-operator.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/overloaded-operator.cpp b/clang/test/SemaCXX/overloaded-operator.cpp index 52d0bff3884..dff9350cc98 100644 --- a/clang/test/SemaCXX/overloaded-operator.cpp +++ b/clang/test/SemaCXX/overloaded-operator.cpp @@ -550,3 +550,38 @@ namespace PR27027 { bool test_global_1 = +a_global; // expected-error {{overload resolution selected deleted operator '+'}} bool test_global_2 = a_global + a_global; // expected-error {{overload resolution selected deleted operator '+'}} } + +namespace LateADLInNonDependentExpressions { + struct A {}; + struct B : A {}; + int &operator+(A, A); + int &operator!(A); + int &operator+=(A, A); + int &operator<<(A, A); + int &operator++(A); + int &operator++(A, int); + int &operator->*(A, A); + + template<typename T> void f() { + // An instantiation-dependent value of type B. + // These are all non-dependent operator calls of type int&. +#define idB ((void()), B()) + int &a = idB + idB, + &b = !idB, + &c = idB += idB, + &d = idB << idB, + &e = ++idB, + &f = idB++, + &g = idB ->* idB; + } + + // These should not be found by ADL in the template instantiation. + float &operator+(B, B); + float &operator!(B); + float &operator+=(B, B); + float &operator<<(B, B); + float &operator++(B); + float &operator++(B, int); + float &operator->*(B, B); + template void f<int>(); +} |

