1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused %s
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // Tests that overload resolution is treated as an unevaluated context.
5*f4a2713aSLionel Sambuc // PR5541
6*f4a2713aSLionel Sambuc struct Foo
7*f4a2713aSLionel Sambuc {
8*f4a2713aSLionel Sambuc     Foo *next;
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc template <typename>
12*f4a2713aSLionel Sambuc struct Bar
13*f4a2713aSLionel Sambuc {
14*f4a2713aSLionel Sambuc };
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc template <typename T>
18*f4a2713aSLionel Sambuc class Wibble
19*f4a2713aSLionel Sambuc {
20*f4a2713aSLionel Sambuc     typedef Bar<T> B;
21*f4a2713aSLionel Sambuc 
concrete(Foo * node)22*f4a2713aSLionel Sambuc     static inline B *concrete(Foo *node) {
23*f4a2713aSLionel Sambuc         int a[sizeof(T) ? -1 : -1];
24*f4a2713aSLionel Sambuc         return reinterpret_cast<B *>(node);
25*f4a2713aSLionel Sambuc     }
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc public:
28*f4a2713aSLionel Sambuc     class It
29*f4a2713aSLionel Sambuc     {
30*f4a2713aSLionel Sambuc         Foo *i;
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc     public:
operator B*() const33*f4a2713aSLionel Sambuc         inline operator B *() const { return concrete(i); }
operator !=(const It & o) const34*f4a2713aSLionel Sambuc         inline bool operator!=(const It &o) const { return i !=
35*f4a2713aSLionel Sambuc o.i; }
36*f4a2713aSLionel Sambuc     };
37*f4a2713aSLionel Sambuc };
38*f4a2713aSLionel Sambuc 
f()39*f4a2713aSLionel Sambuc void f() {
40*f4a2713aSLionel Sambuc   Wibble<void*>::It a, b;
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc   a != b;
43*f4a2713aSLionel Sambuc }
44