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]

PR c++/28346


This simple patch fixes PR c++/28346, an ICE-on-invalid regression.
If we're forming a pointer-to-member expression, we should not discard
the reference type from a qualified-name; that only makes sense if
we're using the expression directly.

Tested on x86_64-unknown-linux-gnu, applied on the mainline.  I will
apply to 4.1 once testing completes.

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

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

	PR c++/28346
	* pt.c (tsubst_qualified_id): Do not strip references from
	OFFSET_REFs. 

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

	PR c++/28346
	* g++.dg/template/ptrmem17.C: New test.

Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 116207)
+++ gcc/cp/pt.c	(working copy)
@@ -7867,7 +7878,11 @@ tsubst_qualified_id (tree qualified_id, 
 	       /*template_arg_p=*/false));
     }
 
-  if (TREE_CODE (expr) != SCOPE_REF)
+  /* Expressions do not generally have reference type.  */
+  if (TREE_CODE (expr) != SCOPE_REF
+      /* However, if we're about to form a pointer-to-member, we just
+	 want the referenced member referenced.  */
+      && TREE_CODE (expr) != OFFSET_REF)
     expr = convert_from_reference (expr);
 
   return expr;
Index: gcc/testsuite/g++.dg/template/ptrmem17.C
===================================================================
--- gcc/testsuite/g++.dg/template/ptrmem17.C	(revision 0)
+++ gcc/testsuite/g++.dg/template/ptrmem17.C	(revision 0)
@@ -0,0 +1,10 @@
+// PR c++/28346
+
+template<int> struct A
+{
+  int& i;
+  A();
+  ~A() { &A::i; } // { dg-error "reference" }
+};
+
+A<0> a; // { dg-error "instantiated" }


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