Patchwork [trans-mem,c++] PR51928

login
register
mail settings
Submitter Patrick Marlier
Date Jan. 24, 2012, 1:57 p.m.
Message ID <4F1EB8E1.6060505@gmail.com>
Download mbox | patch
Permalink /patch/137558/
State New
Headers show

Comments

Patrick Marlier - Jan. 24, 2012, 1:57 p.m.
On 01/24/2012 08:32 AM, Aldy Hernandez wrote:
> On 01/23/12 18:34, Patrick Marlier wrote:
>> Hi,
>>
>> In this PR51928, it tries to look_for_tm_attr_overrides on a thunk but
>> there is no DECL_NAME for thunk. So it fails in
>> lookup_fnfields_idx_nolazy because name is NULL.
>>
>> #0 0x0000000000764b5a in lookup_fnfields_idx_nolazy
>> (type=0x7ffff69f77e0, name=0x0) at ../../trunk/gcc/cp/search.c:1384
>> #1 0x000000000076551a in lookup_fnfields_1 (type=0x7ffff69f77e0,
>> name=0x0) at ../../trunk/gcc/cp/search.c:1470
>> #2 0x000000000076886e in look_for_overrides_here (type=0x7ffff69f77e0,
>> fndecl=0x7ffff69f8800) at ../../trunk/gcc/cp/search.c:2026
>> #3 0x0000000000635a94 in look_for_tm_attr_overrides
>> (type=0x7ffff6a091f8, fndecl=0x7ffff69f8800) at
>> ../../trunk/gcc/cp/class.c:4337
>>
>> I hope the good way to solve this is to use the THUNK_TARGET instead of
>> the thunk itself. (or just ignore when it is a thunk?)
>>
>> Tested on x86_64-unknown-linux-gnu.
>> Thanks.
>> --
>> Patrick Marlier.
>
> I can commit for you, but the testcase is missing, though the changelog
> entry for it is there.

Sorry for the missing testcase. Here the full patch.
Thanks for taking care of the commit.
--
Patrick.

Patch

Index: testsuite/g++.dg/tm/pr51928.C
===================================================================
--- testsuite/g++.dg/tm/pr51928.C	(revision 0)
+++ testsuite/g++.dg/tm/pr51928.C	(revision 0)
@@ -0,0 +1,16 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm" } */
+
+struct A; // { dg-error "forward declaration of 'struct A'" }
+
+struct B
+{
+  virtual B* foo(A);
+};
+
+struct C : virtual B
+{
+  virtual C* foo(A) { return 0; } // { dg-error "'<anonymous>' has incomplete type" }
+};
+
+C c;
Index: cp/class.c
===================================================================
--- cp/class.c	(revision 183448)
+++ cp/class.c	(working copy)
@@ -4430,7 +4430,12 @@  set_method_tm_attributes (tree t)
       tree vchain;
       for (vchain = BINFO_VIRTUALS (TYPE_BINFO (t)); vchain;
 	   vchain = TREE_CHAIN (vchain))
-	set_one_vmethod_tm_attributes (t, BV_FN (vchain));
+	{
+	  fndecl = BV_FN (vchain);
+	  if (DECL_THUNK_P (fndecl))
+	    fndecl = THUNK_TARGET (fndecl);
+	  set_one_vmethod_tm_attributes (t, fndecl);
+	}
     }
 
   /* If the class doesn't have an attribute, nothing more to do.  */