cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 Mar 2003 19:47:17 +0000 (19:47 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 Mar 2003 19:47:17 +0000 (19:47 +0000)
PR c++/9898, PR c++/383, DR 322
* pt.c (maybe_adjust_types_for_deduction) [DEDUCE_CONV]: Look
through reference types on both PARM and ARG.
testsuite:
PR c++/9898, c++/383
* g++.dg/template/conv6.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64815 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 8cc2988..b2d4f79 100644 (file)
@@ -1,4 +1,10 @@
 2003-03-24  Nathan Sidwell  <nathan@codesourcery.com>
+       
+       PR c++/9898, PR c++/383, DR 322
+       * pt.c (maybe_adjust_types_for_deduction) [DEDUCE_CONV]: Look
+       through reference types on both PARM and ARG.
+
+2003-03-24  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/10119
        * error.c (dump_expr) [BASELINK]: Use dump_expr.
index aa9a2c7..3557f9f 100644 (file)
@@ -8753,6 +8753,12 @@ maybe_adjust_types_for_deduction (strict, parm, arg)
       *parm = TREE_TYPE (*parm);
       result |= UNIFY_ALLOW_OUTER_MORE_CV_QUAL;
     }
+
+  /* DR 322. For conversion deduction, remove a reference type on parm
+     too (which has been swapped into ARG).  */
+  if (strict == DEDUCE_CONV && TREE_CODE (*arg) == REFERENCE_TYPE)
+    *arg = TREE_TYPE (*arg);
+  
   return result;
 }
 
index a5f853a..cb6e097 100644 (file)
@@ -1,5 +1,8 @@
 2003-03-24  Nathan Sidwell  <nathan@codesourcery.com>
 
+       PR c++/9898, c++/383
+       * g++.dg/template/conv6.C: New test.
+       
        PR c++/10119
        * g++.dg/template/ptrmem5.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/template/conv6.C b/gcc/testsuite/g++.dg/template/conv6.C
new file mode 100644 (file)
index 0000000..2a4a299
--- /dev/null
@@ -0,0 +1,24 @@
+// { dg-do compile }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 21 Mar 2003 <nathan@codesourcery.com>
+
+// PR 9898, DR 322. Conversion to reference type.
+
+template <typename> struct Ref {};
+template <typename> struct Val {};
+
+struct Wrapper
+{
+  template <typename U> operator Ref<U> & ();
+  template <typename U> operator Val<U> ();
+};
+
+void Foo (Wrapper l)
+{
+  static_cast <Ref<int> &> (l);
+  static_cast <Ref<int> const &> (l);
+  static_cast <Ref<int> > (l);
+  static_cast <Val<int> const &> (l);
+  static_cast <Val<int> > (l);
+}