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 f144d5004cfbf8884d08366186506cfa1f218d80..3745e1a1b71369bc4ec3985886061a5cd2774ecb 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 b6aebaeba22f980f5545d930003a65087b9236a6..3216068811b22cadf7aa9f79c8aff42c08ac65ed 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 e740808ddcba7c8e2b6e837f5416e2c9f5f46b33..f066a80ad707322421b6c1ed7e8401a0516d410d 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);
+}