Properly instantiate usage of overloaded operator []. Fixes PR5345.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85524 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaTemplate/instantiate-subscript.cpp b/test/SemaTemplate/instantiate-subscript.cpp
index 434d84e..20e2c39 100644
--- a/test/SemaTemplate/instantiate-subscript.cpp
+++ b/test/SemaTemplate/instantiate-subscript.cpp
@@ -6,7 +6,7 @@
 };
 
 struct Sub1 {
-  long &operator[](long);
+  long &operator[](long); // expected-note{{candidate function}}
 };
 
 struct ConvertibleToInt {
@@ -24,3 +24,18 @@
 template struct Subscript0<Sub0, int, int&>;
 template struct Subscript0<Sub1, ConvertibleToInt, long&>;
 template struct Subscript0<Sub1, Sub0, long&>; // expected-note{{instantiation}}
+
+// PR5345
+template <typename T>
+struct S {
+  bool operator[](int n) const { return true; }
+};
+
+template <typename T>
+void Foo(const S<int>& s, T x) {
+  if (s[0]) {}
+}
+
+void Bar() {
+  Foo(S<int>(), 0);
+}