This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR c++/48574


Jason Merrill <jason@redhat.com> writes:

> On 04/13/2011 10:23 AM, Jakub Jelinek wrote:
>> Then
>>
>> --- gcc/cp/class.c.jj	2011-04-12 19:43:49.000000000 +0200
>> +++ gcc/cp/class.c	2011-04-13 15:23:07.463670993 +0200
>> @@ -5939,6 +5939,7 @@ fixed_type_or_null (tree instance, int *
>>   	     itself.  */
>>   	  if (TREE_CODE (instance) == VAR_DECL
>>   	&&  DECL_INITIAL (instance)
>> +	&&  !type_dependent_expression_p (DECL_INITIAL (instance))
>>   	&&  !htab_find (ht, instance))
>>   	    {
>>   	      tree type;
>>
>> would be shorter, after that if it returns NULL_TREE.
>
> Yep.

Thanks I am committing this then.

-- 
		Dodji

commit 9ff90e47bafaab67e0c41aa5341a2424726db8a8
Author: Dodji Seketeli <dodji@redhat.com>
Date:   Wed Apr 13 12:30:51 2011 +0200

    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.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index b6aebae..3216068 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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;
diff --git a/gcc/testsuite/g++.dg/template/dependent-expr7.C b/gcc/testsuite/g++.dg/template/dependent-expr7.C
new file mode 100644
index 0000000..b246820
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/dependent-expr7.C
@@ -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);
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]