From patchwork Wed Jan 12 18:38:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [trans-mem] PR46941: Mark new/delete operators as transaction_pure Date: Wed, 12 Jan 2011 08:38:17 -0000 From: Aldy Hernandez X-Patchwork-Id: 78607 Message-Id: <4D2DF519.1020302@redhat.com> To: Richard Henderson , gcc-patches@gcc.gnu.org Same spice, different name. I've used push_cp_library_fn() to mark the function, as opposed to the caller, since only the new/delete operators use this function. OK for branch? * cp/decl.c (push_cp_library_fn): Mark function as transaction_pure. Index: testsuite/g++.dg/tm/pr46941.C =================================================================== --- testsuite/g++.dg/tm/pr46941.C (revision 0) +++ testsuite/g++.dg/tm/pr46941.C (revision 0) @@ -0,0 +1,31 @@ +// { dg-do "compile" } +// { dg-options "-fgnu-tm" } + +class Obj +{ + int dummy; +}; + +__attribute__((transaction_safe)) +Obj* allocate() +{ + return new Obj; +} + +__attribute__((transaction_safe)) +void deallocate(Obj * o) +{ + delete o; +} + +__attribute__((transaction_safe)) +Obj* allocatearray() +{ + return new Obj[2]; +} + +__attribute__((transaction_safe)) +void deallocatearray(Obj *o[]) +{ + delete [] o; +} Index: cp/decl.c =================================================================== --- cp/decl.c (revision 168675) +++ cp/decl.c (working copy) @@ -3775,6 +3775,8 @@ push_cp_library_fn (enum tree_code opera operator_code, type); pushdecl (fn); + if (flag_tm) + apply_tm_attr (fn, get_identifier ("transaction_pure")); return fn; }