]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/38850 (Cannot find inline friend function in template class when called...
authorJason Merrill <jason@redhat.com>
Fri, 16 Jan 2009 06:08:09 +0000 (01:08 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 16 Jan 2009 06:08:09 +0000 (01:08 -0500)
        PR c++/38850
        * pt.c (tsubst_copy_and_build): Tell finish_call_expr to
        accept hidden friends.

From-SVN: r143423

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

index 9708b213866245ff00d7d06bddb9d72a739ed2f1..742f90f75dce9420ea4defe2ae9e721ee948a7c9 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-12  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/36019
index 3bc9edff9a96b8f29087b17272f29205cfac8605..260229f15ad347340fd3aa1c265f1b1672b17c70 100644 (file)
@@ -9317,9 +9317,12 @@ tsubst_copy_and_build (tree t,
                       qualified_p ? LOOKUP_NONVIRTUAL : LOOKUP_NORMAL,
                       /*fn_p=*/NULL));
          }
+       /* 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);
       }
 
     case COND_EXPR:
index 666bc5d7e1024eb17be3acd9258ca4fbfc914981..fc8d3f5c0803f4eb975e8624893971a167bae3dc 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-12  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/36019
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;
+}