re PR c++/38850 (Cannot find inline friend function in template class when called...
authorJason Merrill <jason@redhat.com>
Fri, 16 Jan 2009 05:04:26 +0000 (00:04 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 16 Jan 2009 05:04:26 +0000 (00:04 -0500)
        PR c++/38850
        * pt.c (tsubst_copy_and_build): Tell finish_call_expr to
        accept hidden friends.

From-SVN: r143422

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/koenig6.C [new file with mode: 0644]

index 57ae7570d5fd5f3ff880686e9d2329d882bde3a5..306867419d861cf8f700ea8e6dcd25df3ec54e10 100644 (file)
@@ -1,3 +1,9 @@
+2009-01-15  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38850
+       * pt.c (tsubst_copy_and_build): Tell finish_call_expr to
+       accept hidden friends.
+
 2009-01-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
        PR C++/29388
index 0618fe2432876f74d7733c4bfa4705f9e50b0102..0378d39be123fbf6262536601d0fef0e5554cbd0 100644 (file)
@@ -11400,9 +11400,12 @@ tsubst_copy_and_build (tree t,
                       /*fn_p=*/NULL,
                       complain));
          }
+       /* Pass true for koenig_p so that build_new_function_call will
+          allow hidden friends found by arg-dependent lookup at template
+          parsing time.  */
        return finish_call_expr (function, call_args,
                                 /*disallow_virtual=*/qualified_p,
-                                koenig_p,
+                                /*koenig_p*/true,
                                 complain);
       }
 
index 3e46d1fc97177b6912dddd9b4e8fa9ec776517d2..0a4383f755bb8890916ad76e5290b2e74f419d8d 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-15  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38850
+       * g++.dg/template/koenig6.C: New test.
+
 2009-01-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
         PR C++/29388
diff --git a/gcc/testsuite/g++.dg/template/koenig6.C b/gcc/testsuite/g++.dg/template/koenig6.C
new file mode 100644 (file)
index 0000000..8f93a65
--- /dev/null
@@ -0,0 +1,29 @@
+// PR c++/38850
+
+template <typename VType>
+class Vector2 {
+ private:
+  VType c_[2];
+ public:
+  typedef Vector2<VType> Self;
+
+  Vector2(const VType x, const VType y) {
+    c_[0] = x;
+    c_[1] = y;
+  }
+
+  friend inline Self Max(const Self &v1, const Self &v2) {
+    return Self(v1.c_[0], v1.c_[1]);
+  }
+};
+
+template <class T>
+Vector2<float> foo(T x) {
+  Vector2<float> y(0,0);
+  return Max(y, y);
+}
+
+int main() {
+  foo(3);
+  return 0;
+}