re PR c++/48574 (ICE)
authorDodji Seketeli <dodji@redhat.com>
Wed, 13 Apr 2011 15:09:26 +0000 (15:09 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Wed, 13 Apr 2011 15:09:26 +0000 (17:09 +0200)
Fix PR c++/48574

gcc/cp/

* class.c (fixed_type_or_null): We cannot determine the dynamic
type of a reference variable if its initializer is dependent.

gcc/testsuite/

* g++.dg/template/dependent-expr7.C: New test case.

From-SVN: r172375

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/dependent-expr7.C [new file with mode: 0644]

index f144d50..3745e1a 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-13  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/48574
+       * class.c (fixed_type_or_null): We cannot determine the dynamic
+       type of a reference variable if its initializer is dependent.
+
 2011-04-13  Jason Merrill  <jason@redhat.com>
 
        PR c++/48581
index b6aebae..3216068 100644 (file)
@@ -5939,6 +5939,7 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp)
             itself.  */
          if (TREE_CODE (instance) == VAR_DECL
              && DECL_INITIAL (instance)
+             && !type_dependent_expression_p (DECL_INITIAL (instance))
              && !htab_find (ht, instance))
            {
              tree type;
index e740808..f066a80 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-13  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/48574
+       * g++.dg/template/dependent-expr7.C: New test case.
+
 2011-04-13  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/sfinae13.C: New.
diff --git a/gcc/testsuite/g++.dg/template/dependent-expr7.C b/gcc/testsuite/g++.dg/template/dependent-expr7.C
new file mode 100644 (file)
index 0000000..b246820
--- /dev/null
@@ -0,0 +1,22 @@
+// Origin PR c++/48574
+// { dg-do compile }
+
+struct A
+{
+  virtual void foo();
+};
+
+template <typename T>
+void
+bar(T x)
+{
+  A &b = *x;
+  b.foo ();
+}
+
+void
+foo()
+{
+  A a;
+  bar(&a);
+}