This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 28557


This patch fixes PR c++/28557, an ICE-on-valid regression.  The
problem here was simply that we had forgotten to substitute into
BASELINK_OPTYPE in templates.

Tested on x86_64-unknown-linux-gnu, applied on the mainline and on the
4.1 branch.

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

2006-08-01  Mark Mitchell  <mark@codesourcery.com>

	PR c++/28557
	* pt.c (tsubst_baselink): Substitute into BASELINK_OPTYPE.

2006-08-01  Mark Mitchell  <mark@codesourcery.com>

	PR c++/28557
	* g++.dg/template/conv9.C: New test.

Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 115861)
+++ gcc/cp/pt.c	(working copy)
@@ -7675,6 +7675,7 @@ tsubst_baselink (tree baselink, tree obj
     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 obj
        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 obj
 	= 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: gcc/testsuite/g++.dg/template/conv9.C
===================================================================
--- gcc/testsuite/g++.dg/template/conv9.C	(revision 0)
+++ gcc/testsuite/g++.dg/template/conv9.C	(revision 0)
@@ -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>();
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]