public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR c++/48574
@ 2011-05-05 23:15 Dodji Seketeli
  2011-05-06  0:39 ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Dodji Seketeli @ 2011-05-05 23:15 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jason Merrill

Hello,

This is a leftover of the fix for PR c++/48574.  When
fold_non_dependent_expr sees the lvalue reference 'b' in the example
of the patch below (because in finish_call_expr,
make_args_non_dependent on 'b' calls build_non_dependent_expr which
calls null_ptr_cst_p which calls fold_non_dependent_expr), it
indirectly calls fixed_type_or_null.

The problem is that fold_non_dependent_expr unsets
processing_template_decl, so the type_dependent_expression_p test I
have added to fix PR c++/48574 returns immediately.

So this patch uses uses_template_parms instead of
type_dependent_expression_p.

Tested and bootstrapped on x86_64-unknown-linux-gnu against trunk and
4.6.

OK to commit to trunk and to 4.6?

gcc/cp/

	PR c++/48574
	* class.c (fixed_type_or_null): Use uses_template_parms to test if
	the instance is dependent.

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

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 9af238b..6fcc3c5 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))
+	      && !uses_template_parms (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);
+}
-- 
		Dodji

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix PR c++/48574
  2011-05-05 23:15 [PATCH] Fix PR c++/48574 Dodji Seketeli
@ 2011-05-06  0:39 ` Jason Merrill
  2011-05-06 11:13   ` Dodji Seketeli
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2011-05-06  0:39 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: GCC Patches

How about type_dependent_expression_p_push instead?

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix PR c++/48574
  2011-05-06  0:39 ` Jason Merrill
@ 2011-05-06 11:13   ` Dodji Seketeli
  2011-05-06 13:10     ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Dodji Seketeli @ 2011-05-06 11:13 UTC (permalink / raw)
  To: Jason Merrill; +Cc: GCC Patches

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

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);
+}
-- 
		Dodji

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix PR c++/48574
  2011-05-06 11:13   ` Dodji Seketeli
@ 2011-05-06 13:10     ` Jason Merrill
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2011-05-06 13:10 UTC (permalink / raw)
  To: Dodji Seketeli; +Cc: GCC Patches

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-06 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-05 23:15 [PATCH] Fix PR c++/48574 Dodji Seketeli
2011-05-06  0:39 ` Jason Merrill
2011-05-06 11:13   ` Dodji Seketeli
2011-05-06 13:10     ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).