xref: /llvm-project/clang/test/SemaTemplate/overload-uneval.cpp (revision c6e68daac0fa6e77a89f3ca72f266a528503dd1c)
146339475SChandler Carruth // RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused %s
2*c6e68daaSAndy Gibbs // expected-no-diagnostics
327381f3dSDouglas Gregor 
427381f3dSDouglas Gregor // Tests that overload resolution is treated as an unevaluated context.
527381f3dSDouglas Gregor // PR5541
627381f3dSDouglas Gregor struct Foo
727381f3dSDouglas Gregor {
827381f3dSDouglas Gregor     Foo *next;
927381f3dSDouglas Gregor };
1027381f3dSDouglas Gregor 
1127381f3dSDouglas Gregor template <typename>
1227381f3dSDouglas Gregor struct Bar
1327381f3dSDouglas Gregor {
1427381f3dSDouglas Gregor };
1527381f3dSDouglas Gregor 
1627381f3dSDouglas Gregor 
1727381f3dSDouglas Gregor template <typename T>
1827381f3dSDouglas Gregor class Wibble
1927381f3dSDouglas Gregor {
2027381f3dSDouglas Gregor     typedef Bar<T> B;
2127381f3dSDouglas Gregor 
concrete(Foo * node)2227381f3dSDouglas Gregor     static inline B *concrete(Foo *node) {
2327381f3dSDouglas Gregor         int a[sizeof(T) ? -1 : -1];
2427381f3dSDouglas Gregor         return reinterpret_cast<B *>(node);
2527381f3dSDouglas Gregor     }
2627381f3dSDouglas Gregor 
2727381f3dSDouglas Gregor public:
2827381f3dSDouglas Gregor     class It
2927381f3dSDouglas Gregor     {
3027381f3dSDouglas Gregor         Foo *i;
3127381f3dSDouglas Gregor 
3227381f3dSDouglas Gregor     public:
operator B*() const3327381f3dSDouglas Gregor         inline operator B *() const { return concrete(i); }
operator !=(const It & o) const3427381f3dSDouglas Gregor         inline bool operator!=(const It &o) const { return i !=
3527381f3dSDouglas Gregor o.i; }
3627381f3dSDouglas Gregor     };
3727381f3dSDouglas Gregor };
3827381f3dSDouglas Gregor 
f()3927381f3dSDouglas Gregor void f() {
4027381f3dSDouglas Gregor   Wibble<void*>::It a, b;
4127381f3dSDouglas Gregor 
4227381f3dSDouglas Gregor   a != b;
4327381f3dSDouglas Gregor }
44