diff mbox

C++ PATCH for c++/48749 (ICE regression in template)

Message ID 4DC1D127.2040804@redhat.com
State New
Headers show

Commit Message

Jason Merrill May 4, 2011, 10:20 p.m. UTC
The problem was that fixed_type_or_null was looking closely at things 
that aren't meant to be looked at closely when we're in templates, 
namely a COMPONENT_REF where operand 1 is an IDENTIFIER.  In a template 
we're going to discard the conversion anyway once we decide it's OK, so 
we might as well take the easy way out.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 58f7b3e610d3fcc14e2c29ae6acf62c0c8a938bc
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 4 15:45:12 2011 -0400

    	PR c++/48749
    	* class.c (resolves_to_fixed_type_p): Don't look closely
    	in templates.
diff mbox

Patch

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 9af238b..a67b34a 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5980,7 +5980,17 @@  resolves_to_fixed_type_p (tree instance, int* nonnull)
 {
   tree t = TREE_TYPE (instance);
   int cdtorp = 0;
-  tree fixed = fixed_type_or_null (instance, nonnull, &cdtorp);
+  tree fixed;
+
+  if (processing_template_decl)
+    {
+      /* In a template we only care about the type of the result.  */
+      if (nonnull)
+	*nonnull = true;
+      return true;
+    }
+
+  fixed = fixed_type_or_null (instance, nonnull, &cdtorp);
   if (fixed == NULL_TREE)
     return 0;
   if (POINTER_TYPE_P (t))
diff --git a/gcc/testsuite/g++.dg/conversion/base1.C b/gcc/testsuite/g++.dg/conversion/base1.C
new file mode 100644
index 0000000..e236504
--- /dev/null
+++ b/gcc/testsuite/g++.dg/conversion/base1.C
@@ -0,0 +1,20 @@ 
+// PR c++/48749
+
+struct Tuple3
+{
+  float x;
+};
+
+struct Pos: virtual Tuple3 { };
+
+struct TexCoords
+{
+  Pos pos;
+};
+
+template <class T>
+void eval (const TexCoords &coords)
+{
+  const Pos &pos = coords.pos;
+  pos.x;
+}