Patchwork Fix PR c++/48574

login
register
mail settings
Submitter Dodji Seketeli
Date May 6, 2011, 11:08 a.m.
Message ID <m3iptow0gm.fsf@redhat.com>
Download mbox | patch
Permalink /patch/94361/
State New
Headers show

Comments

Dodji Seketeli - May 6, 2011, 11:08 a.m.
Jason Merrill <jason@redhat.com> writes:

> How about type_dependent_expression_p_push instead?

Like this ?  Lightly tested.  A full bootstrap and regression test is
under way.

Thanks.

gcc/cp/

	PR c++/48574 * class.c (fixed_type_or_null): Use
	type_dependent_p_push to test if the instance has a dependent
	initializer.

gcc/testsuite/

	PR c++/48574
	* g++.dg/template/dependent-expr8.C: New test case.
---
 gcc/cp/class.c                                  |    2 +-
 gcc/testsuite/g++.dg/template/dependent-expr8.C |   25 +++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/template/dependent-expr8.C
Jason Merrill - May 6, 2011, 1:06 p.m.
On 05/06/2011 07:08 AM, Dodji Seketeli wrote:
> Jason Merrill<jason@redhat.com>  writes:
>
>> How about type_dependent_expression_p_push instead?
>
> Like this ?  Lightly tested.  A full bootstrap and regression test is
> under way.

OK.

Jason

Patch

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index a67b34a..6b08a03 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5939,7 +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))
+	      && !type_dependent_expression_p_push (DECL_INITIAL (instance))
 	      && !htab_find (ht, instance))
 	    {
 	      tree type;
diff --git a/gcc/testsuite/g++.dg/template/dependent-expr8.C b/gcc/testsuite/g++.dg/template/dependent-expr8.C
new file mode 100644
index 0000000..20014d6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/dependent-expr8.C
@@ -0,0 +1,25 @@ 
+// Origin PR c++/48574
+// { dg-options "-std=c++0x" }
+// { dg-do compile }
+
+struct A
+{
+  virtual int foo();
+};
+
+void baz (int);
+
+template <typename T>
+void
+bar(T x)
+{
+  A &b = *x;
+  baz (b.foo ());
+}
+
+void
+foo()
+{
+  A a;
+  bar(&a);
+}