re PR c++/28557 (Trouble with templated type conversion operator)
authorMark Mitchell <mark@codesourcery.com>
Wed, 2 Aug 2006 20:35:41 +0000 (20:35 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 2 Aug 2006 20:35:41 +0000 (20:35 +0000)
PR c++/28557
* pt.c (tsubst_baselink): Substitute into BASELINK_OPTYPE.
PR c++/28557
* g++.dg/template/conv9.C: New test.

From-SVN: r115886

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

index 1e327c22e76efb8775a257336dc79c8b7adc863f..9feacb451bc975d57a056eebd599b5dd4e38f16b 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-02  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/28557
+       * pt.c (tsubst_baselink): Substitute into BASELINK_OPTYPE.
+
 2006-07-31  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/28523
index 30e6cd09a4b301df0ec7f89e1c965e31a9610394..c0205a419c7c2c4fa5bcd8d71ed01c54a4096de0 100644 (file)
@@ -7675,6 +7675,7 @@ tsubst_baselink (tree baselink, tree object_type,
     tree name;
     tree qualifying_scope;
     tree fns;
+    tree optype;
     tree template_args = 0;
     bool template_id_p = false;
 
@@ -7688,6 +7689,7 @@ tsubst_baselink (tree baselink, tree object_type,
        ambiguous now.  Therefore, we perform the lookup again.  */
     qualifying_scope = BINFO_TYPE (BASELINK_ACCESS_BINFO (baselink));
     fns = BASELINK_FUNCTIONS (baselink);
+    optype = BASELINK_OPTYPE (baselink);
     if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
       {
        template_id_p = true;
@@ -7715,6 +7717,9 @@ tsubst_baselink (tree baselink, tree object_type,
        = build_nt (TEMPLATE_ID_EXPR,
                    BASELINK_FUNCTIONS (baselink),
                    template_args);
+    /* Update the conversion operator type.  */
+    BASELINK_OPTYPE (baselink) 
+      = tsubst (optype, args, complain, in_decl);
 
     if (!object_type)
       object_type = current_class_type;
index 8aa4e1a1778aa6c3c5abab08a07bd5779dbf4b4e..4df1b9a5945c218df6adfbb1e712cc2dda634a52 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-02  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/28557
+       * g++.dg/template/conv9.C: New test.
+
 2006-08-02  Daniel Jacobowitz  <dan@codesourcery.com>
 
        PR debug/28063
diff --git a/gcc/testsuite/g++.dg/template/conv9.C b/gcc/testsuite/g++.dg/template/conv9.C
new file mode 100644 (file)
index 0000000..269e338
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/28557
+
+struct A
+{
+  template<typename T> operator T() { return T(); }
+};
+
+template<int> void foo()
+{
+  A().operator int();
+}
+
+void bar()
+{
+  foo<0>();
+}