Index: gcc/testsuite/g++.dg/tm/wrap-2.C
===================================================================
--- gcc/testsuite/g++.dg/tm/wrap-2.C    (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/wrap-2.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm" } */
+
+#define W(X)   __attribute__((transaction_wrap(X)))
+void f1(void);
+void f2(int);
+int i3;
+int f7(void);
+
+void g1(void) W(f1);
+void g2(void) W(f2);   /* { dg-error "is not compatible" } */
+void g3(void) W(i3);   /* { dg-error "is not a function" } */
+void g4(void) W(f4); /* { dg-error "not declared in this scope\|not an identifier" } */
+void g5(void) W(1);    /* { dg-error "not an identifier" } */
+void g6(void) W("f1");       /* { dg-error "not an identifier" } */
+void g7(void) W(f7);   /* { dg-error "is not compatible" } */
Index: gcc/testsuite/g++.dg/tm/pr46300.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr46300.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr46300.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,8 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+void foo(){
+    __transaction_atomic {
+        throw 5;
+    }
+}
Index: gcc/testsuite/g++.dg/tm/fatomic-1.C
===================================================================
--- gcc/testsuite/g++.dg/tm/fatomic-1.C (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/fatomic-1.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,10 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+struct S
+{
+  int i, j, k;
+  S();
+};
+
+S::S() __transaction_atomic : i(1), j(2), k(3) { }
Index: gcc/testsuite/g++.dg/tm/nested-1.C
===================================================================
--- gcc/testsuite/g++.dg/tm/nested-1.C  (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/nested-1.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,22 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+class HashTree
+{
+public:
+   __attribute__((transaction_safe))
+   int add_element2();
+private:
+   int Count;
+};
+
+
+__attribute__((transaction_safe))
+int HashTree::add_element2()
+{
+ int tt;
+  __transaction_atomic {
+    tt = Count;
+ }
+ return tt;
+}
Index: gcc/testsuite/g++.dg/tm/nested-2.C
===================================================================
--- gcc/testsuite/g++.dg/tm/nested-2.C  (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/nested-2.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,41 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O" }
+
+typedef unsigned long int uint64_t;
+extern int *hash_indx;
+
+typedef struct
+{
+  uint64_t exit_atomicsec_time;
+} ent_ex_times;
+class HashTree
+{
+public:
+   __attribute__((transaction_safe))
+   void *operator new(__SIZE_TYPE__);
+   __attribute__((transaction_safe))
+   int add_element();
+private:
+   HashTree **Hash_table;
+   int Count;
+};
+
+
+__attribute__((transaction_safe))
+int HashTree::add_element()
+{
+ ent_ex_times enter_exit_times_inside;
+ int val = hash_indx[5];
+ int tt;
+ if (Hash_table[val] == __null)
+ {
+  __transaction_atomic {
+    Hash_table[val] = new HashTree;
+  }
+ }
+ __transaction_atomic {
+ tt = Count++;
+ enter_exit_times_inside.exit_atomicsec_time = 5;
+ }
+ return tt;
+}
Index: gcc/testsuite/g++.dg/tm/nested-3.C
===================================================================
--- gcc/testsuite/g++.dg/tm/nested-3.C  (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/nested-3.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,43 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O0" }
+
+// Same as nested-2.C but with no optimization.
+
+typedef unsigned long int uint64_t;
+extern int *hash_indx;
+
+typedef struct
+{
+  uint64_t exit_atomicsec_time;
+} ent_ex_times;
+class HashTree
+{
+public:
+   __attribute__((transaction_safe))
+   void *operator new(__SIZE_TYPE__);
+   __attribute__((transaction_safe))
+   int add_element();
+private:
+   HashTree **Hash_table;
+   int Count;
+};
+
+
+__attribute__((transaction_safe))
+int HashTree::add_element()
+{
+ ent_ex_times enter_exit_times_inside;
+ int val = hash_indx[5];
+ int tt;
+ if (Hash_table[val] == __null)
+ {
+  __transaction_atomic {
+    Hash_table[val] = new HashTree;
+  }
+ }
+ __transaction_atomic {
+ tt = Count++;
+ enter_exit_times_inside.exit_atomicsec_time = 5;
+ }
+ return tt;
+}
Index: gcc/testsuite/g++.dg/tm/pr47340.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr47340.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr47340.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,11 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+void* operator new(__SIZE_TYPE__) throw (int);
+
+void *point;
+
+void funky()
+{
+  point = new (int);
+}
Index: gcc/testsuite/g++.dg/tm/pr47530.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr47530.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr47530.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,79 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O2 -fdump-tree-optimized" }
+
+typedef __SIZE_TYPE__ size_t;
+extern void *malloc(size_t);
+
+namespace bench
+{
+    class LLNode
+    {
+       LLNode* next;
+       int data;
+
+    public:
+        __attribute__((transaction_safe))
+       LLNode(int val, LLNode* m_next)
+        {
+               data = val;
+               next = m_next;
+        }
+        __attribute__((transaction_safe))
+         ~LLNode(){}
+        __attribute__((transaction_safe))
+         int get_val()  {return data;}
+        __attribute__((transaction_safe))
+         LLNode* get_next()  {return next;}
+       __attribute__((transaction_safe))
+         void set_val(int val) {data = val;}
+        __attribute__((transaction_safe))
+         void set_next(LLNode* n)  {next = n;}
+        __attribute__((transaction_safe))
+         void *operator new(size_t size);
+    };
+
+    class LinkedList
+    {
+      LLNode* head;
+    public:
+        LinkedList();
+        void insert(int val);
+    };
+}
+
+using bench::LinkedList;
+using bench::LLNode;
+
+
+__attribute__((transaction_safe))
+void* LLNode::operator new(size_t size)
+{
+  return malloc(size);
+}
+
+LinkedList::LinkedList() : head(new LLNode(-1, 0)) { }
+
+void LinkedList::insert(int val)
+{
+  __transaction_atomic {
+    LLNode* prev = head;
+    LLNode* curr = head->get_next();
+
+    while (curr != 0) {
+      if (curr->get_val() >= val)
+       break;
+      prev = curr;
+      curr = prev->get_next();
+    }
+
+    if (!curr || (curr->get_val() > val)){
+      LLNode* tmp = new LLNode(val,curr);
+      prev->set_next(tmp);
+    }
+  }
+}
+
+// Make sure we don't do tail optimization on the commit.
+// { dg-final { scan-tree-dump-times "commitTransaction...; .tail call" 0 "optimized" } }
+// { dg-final { cleanup-tree-dump "optimized" } }
+
Index: gcc/testsuite/g++.dg/tm/pr46270.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr46270.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr46270.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,27 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+#include <list>
+class Game
+{
+public:
+  struct BuildProject
+  {
+    int posX;
+  };
+  std::list<BuildProject> buildProjects;
+};
+
+static Game game;
+static std::list<std::list<Game::BuildProject>::iterator> erasableBuildProjects;
+
+static void *buildProjectSyncStepConcurrently(int id, int localTeam)
+{
+  __transaction_relaxed {
+    std::list<std::list<Game::BuildProject>::iterator>::iterator it
+      = erasableBuildProjects.begin();
+    game.buildProjects.erase( (std::list<Game::BuildProject>
+                              ::iterator) *it);
+  }
+  return 0;
+}
Index: gcc/testsuite/g++.dg/tm/attrib-2.C
===================================================================
--- gcc/testsuite/g++.dg/tm/attrib-2.C  (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/attrib-2.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,22 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -fdump-tree-optimized-asmname" }
+
+struct __attribute__((transaction_safe)) Tsafe
+{
+  void f();
+};
+
+void Tsafe::f() { }
+
+struct __attribute__((transaction_callable)) Tcall
+{
+  void f();
+};
+
+void Tcall::f() { }
+
+// { dg-final { scan-tree-dump-times "_ZN5Tsafe1fEv" 1 "optimized" } }
+// { dg-final { scan-tree-dump-times "_ZN5Tcall1fEv" 1 "optimized" } }
+// { dg-final { scan-tree-dump-times "_ZGTtN5Tsafe1fEv" 1 "optimized" } }
+// { dg-final { scan-tree-dump-times "_ZGTtN5Tcall1fEv" 1 "optimized" } }
+// { dg-final { cleanup-tree-dump "optimized" } }
Index: gcc/testsuite/g++.dg/tm/attrib-3.C
===================================================================
--- gcc/testsuite/g++.dg/tm/attrib-3.C  (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/attrib-3.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,33 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -fdump-tree-optimized-asmname" }
+
+struct __attribute__((transaction_safe)) A
+{
+};
+
+struct B : public A
+{
+  void f();
+};
+
+struct C
+{
+};
+
+struct D : public C
+{
+};
+
+struct E : public D, public A
+{
+  void f();
+};
+
+void B::f() { }
+void E::f() { }
+
+// { dg-final { scan-tree-dump-times "_ZN1B1fEv" 1 "optimized" } }
+// { dg-final { scan-tree-dump-times "_ZGTtN1B1fEv" 1 "optimized" } }
+// { dg-final { scan-tree-dump-times "_ZN1E1fEv" 1 "optimized" } }
+// { dg-final { scan-tree-dump-times "_ZGTtN1E1fEv" 1 "optimized" } }
+// { dg-final { cleanup-tree-dump "optimized" } }
Index: gcc/testsuite/g++.dg/tm/pr45940-2.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr45940-2.C (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr45940-2.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,30 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O1" }
+
+__attribute__((transaction_pure))
+inline int atomic_exchange_and_add(int dv )
+{
+    int r;
+    __asm__ ("" : "=r"(r));
+    return r;
+}
+
+class sp_counted_base
+{
+public:
+    __attribute__((transaction_safe))
+    void release()
+    {
+        if( atomic_exchange_and_add(-1 ) == 1 )
+        {
+        }
+    }
+};
+
+sp_counted_base *base;
+
+void here(){
+  __transaction_atomic {
+    base->release();
+  }
+}
Index: gcc/testsuite/g++.dg/tm/attrib-4.C
===================================================================
--- gcc/testsuite/g++.dg/tm/attrib-4.C  (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/attrib-4.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,48 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+#define __ts   __attribute__((transaction_safe))
+#define __tc   __attribute__((transaction_callable))
+#define __tp   __attribute__((transaction_pure))
+#define __tu   __attribute__((transaction_unsafe))
+
+struct __ts A
+{
+  virtual void f();
+  virtual void g();
+};
+
+struct __tc B : public A
+{
+ void f() __tc; // { dg-error ".transaction_callable. overriding .transaction_safe." }
+  void g();
+  virtual void h();
+};
+
+struct C : public B
+{
+ void g() __tc; // { dg-error ".transaction_callable. overriding .transaction_safe." }
+};
+
+struct C2 : public B
+{
+  void g() __ts;
+ void h() __tu; // { dg-error ".transaction_unsafe. overriding .transaction_callable." }
+};
+
+struct D
+{
+  virtual void f() __tp;
+  virtual void g() __tp;
+};
+
+struct E : public D
+{
+ void f() __ts; // { dg-error ".transaction_safe. overriding .transaction_pure." }
+  void g();
+};
+
+struct F : public E
+{
+ void g() __ts; // { dg-error ".transaction_safe. overriding .transaction_pure." }
+};
Index: gcc/testsuite/g++.dg/tm/pr45940.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr45940.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr45940.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,30 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O0" }
+
+__attribute__((transaction_pure))
+inline int atomic_exchange_and_add(int dv )
+{
+    int r;
+    __asm__ ("" : "=r"(r));
+    return r;
+}
+
+class sp_counted_base
+{
+public:
+    __attribute__((transaction_safe))
+    void release()
+    {
+        if( atomic_exchange_and_add(-1 ) == 1 )
+        {
+        }
+    }
+};
+
+sp_counted_base *base;
+
+void here(){
+  __transaction_atomic {
+    base->release();
+  }
+}
Index: gcc/testsuite/g++.dg/tm/pr45940-3.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr45940-3.C (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr45940-3.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,69 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O0" }
+
+__attribute__((transaction_safe))
+void* operator new (__SIZE_TYPE__);
+
+__attribute__((transaction_pure))
+inline int atomic_exchange_and_add( int * pw, int dv )
+{
+    int r;
+    __asm__ ("" : "=r"(r));
+    return r;
+}
+
+class sp_counted_base
+{
+protected:
+    int use_count_;        // #shared
+public:
+    __attribute__((transaction_safe))
+    virtual void dispose() = 0; // nothrow
+
+    __attribute__((transaction_safe))
+    void release() // nothrow
+    {
+        if( atomic_exchange_and_add( &use_count_, -1 ) == 1 )
+        {
+            dispose();
+        }
+    }
+};
+
+class sp_counted_base_x86 : public sp_counted_base
+{
+public:
+  void dispose()
+  {
+    release();
+  }
+};
+
+class shared_count
+{
+private:
+    sp_counted_base * pi_;
+public:
+    int j;
+    __attribute__((transaction_safe))
+    shared_count(): pi_(new sp_counted_base_x86()), j(0)
+    {
+    }
+    __attribute__((transaction_safe))
+    ~shared_count() // nothrow
+    {
+        if( pi_ != 0 ) pi_->release();
+    }
+};
+
+volatile int i = 1;
+shared_count * c;
+int main()
+{
+  if ( i == 0) {
+    __transaction_atomic {
+     shared_count sc;
+    }
+  }
+  return 0;
+}
Index: gcc/testsuite/g++.dg/tm/pr46714.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr46714.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr46714.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O" }
+
+static int asdf __attribute__ ((__weakref__("funky")));
+
+class Building
+{      
+public:
+  __attribute__((transaction_safe)) ~Building(void);
+};
+
+Building::~Building()
+{
+}
Index: gcc/testsuite/g++.dg/tm/pr45940-4.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr45940-4.C (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr45940-4.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,69 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O1" }
+
+__attribute__((transaction_safe))
+void* operator new (__SIZE_TYPE__);
+
+__attribute__((transaction_pure))
+inline int atomic_exchange_and_add( int * pw, int dv )
+{
+    int r;
+    __asm__ ("" : "=r"(r));
+    return r;
+}
+
+class sp_counted_base
+{
+protected:
+    int use_count_;        // #shared
+public:
+    __attribute__((transaction_safe))
+    virtual void dispose() = 0; // nothrow
+
+    __attribute__((transaction_safe))
+    void release() // nothrow
+    {
+        if( atomic_exchange_and_add( &use_count_, -1 ) == 1 )
+        {
+            dispose();
+        }
+    }
+};
+
+class sp_counted_base_x86 : public sp_counted_base
+{
+public:
+  void dispose()
+  {
+    release();
+  }
+};
+
+class shared_count
+{
+private:
+    sp_counted_base * pi_;
+public:
+    int j;
+    __attribute__((transaction_safe))
+    shared_count(): pi_(new sp_counted_base_x86()), j(0)
+    {
+    }
+    __attribute__((transaction_safe))
+    ~shared_count() // nothrow
+    {
+        if( pi_ != 0 ) pi_->release();
+    }
+};
+
+volatile int i = 1;
+shared_count * c;
+int main()
+{
+  if ( i == 0) {
+    __transaction_atomic {
+     shared_count sc;
+    }
+  }
+  return 0;
+}
Index: gcc/testsuite/g++.dg/tm/alias.C
===================================================================
--- gcc/testsuite/g++.dg/tm/alias.C     (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/alias.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O0" }
+
+/* Test that we generate transactional clones for both the base and
+   the complete dtor for class Itemset.  */
+
+class Itemset {
+public:
+   __attribute__((transaction_safe)) ~Itemset();
+  __attribute__((transaction_safe)) void operator delete(void *);
+private:
+};
+
+__attribute__((transaction_safe))
+Itemset::~Itemset()
+{
+}
+
+// { dg-final { scan-assembler "_ZGTtN7ItemsetD1Ev" } }
+// { dg-final { scan-assembler "_ZGTtN7ItemsetD2Ev" } }
Index: gcc/testsuite/g++.dg/tm/pr46653.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr46653.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr46653.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O" }
+
+class shared_count
+{
+public:
+    volatile int j;
+  shared_count() : j(0) { }
+};
+
+shared_count * c;
+int main()
+{
+  __transaction_atomic {
+    shared_count sc;
+  }
+  return 0;
+}
Index: gcc/testsuite/g++.dg/tm/pr46941.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr46941.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr46941.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,37 @@
+// { 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;
+}
+
+/* The delete/new operators are handled by the libitm runtime.  */
+/* { dg-final { scan-assembler "_ZGTtnw\[mj\]" } } */
+/* { dg-final { scan-assembler "_ZGTtna\[mj\]" } } */
+/* { dg-final { scan-assembler "_ZGTtdlPv" } } */
+/* { dg-final { scan-assembler "_ZGTtdaPv" } } */
Index: gcc/testsuite/g++.dg/tm/pr47554.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr47554.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr47554.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,27 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+class list
+{
+       public:     list()
+       {
+       }
+       list(const list&)
+       {
+       }
+       const list&       _M_get_Node_allocator() const
+       {
+       }
+       list       _M_get_Tp_allocator() const
+       {
+               return list(_M_get_Node_allocator());
+       }
+};
+static list buildProjects;
+static void build()
+{
+       __transaction_relaxed
+       {
+               buildProjects._M_get_Tp_allocator();
+       }
+}
Index: gcc/testsuite/g++.dg/tm/tm.exp
===================================================================
--- gcc/testsuite/g++.dg/tm/tm.exp      (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/tm.exp (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,39 @@
+#   Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib g++-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CXXFLAGS
+if ![info exists DEFAULT_CXXFLAGS] then {
+    set DEFAULT_CXXFLAGS " -ansi -pedantic-errors -Wno-long-long"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Run the tests that are shared with C.
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/tm/*.c]] \
+       "" $DEFAULT_CXXFLAGS
+# Run the C++ only tests.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] \
+       "" $DEFAULT_CXXFLAGS
+
+# All done.
+dg-finish
Index: gcc/testsuite/g++.dg/tm/pr46646.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr46646.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr46646.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,890 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O0"}
+
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  template<class _T1, class _T2>
+    struct pair
+    {
+      typedef _T1 first_type;
+      typedef _T2 second_type;
+      _T1 first;
+      _T2 second;
+      pair()
+      : first(), second() { }
+      pair(const _T1& __a, const _T2& __b)
+      : first(__a), second(__b) { }
+    };
+}
+
+
+typedef long int ptrdiff_t;
+typedef __SIZE_TYPE__ size_t;
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  using ::ptrdiff_t;
+  using ::size_t;
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  struct input_iterator_tag { };
+  struct output_iterator_tag { };
+  struct forward_iterator_tag : public input_iterator_tag { };
+  struct bidirectional_iterator_tag : public forward_iterator_tag { };
+ struct random_access_iterator_tag : public bidirectional_iterator_tag { }; + template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
+           typename _Pointer = _Tp*, typename _Reference = _Tp&>
+    struct iterator
+    {
+      typedef _Category iterator_category;
+      typedef _Tp value_type;
+      typedef _Distance difference_type;
+      typedef _Pointer pointer;
+      typedef _Reference reference;
+    };
+  template<typename _Iterator>
+    struct iterator_traits
+    {
+      typedef typename _Iterator::iterator_category iterator_category;
+      typedef typename _Iterator::value_type value_type;
+      typedef typename _Iterator::difference_type difference_type;
+      typedef typename _Iterator::pointer pointer;
+      typedef typename _Iterator::reference reference;
+    };
+  template<typename _Tp>
+    struct iterator_traits<_Tp*>
+    {
+      typedef random_access_iterator_tag iterator_category;
+      typedef _Tp value_type;
+      typedef ptrdiff_t difference_type;
+      typedef _Tp* pointer;
+      typedef _Tp& reference;
+    };
+  template<typename _Tp>
+    struct iterator_traits<const _Tp*>
+    {
+      typedef random_access_iterator_tag iterator_category;
+      typedef _Tp value_type;
+      typedef ptrdiff_t difference_type;
+      typedef const _Tp* pointer;
+      typedef const _Tp& reference;
+    };
+  template<typename _Iter>
+    inline typename iterator_traits<_Iter>::iterator_category
+    __iterator_category(const _Iter&)
+    { return typename iterator_traits<_Iter>::iterator_category(); }
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  template<typename _Iterator>
+    class reverse_iterator
+ : public iterator<typename iterator_traits<_Iterator>::iterator_category,
+        typename iterator_traits<_Iterator>::value_type,
+        typename iterator_traits<_Iterator>::difference_type,
+        typename iterator_traits<_Iterator>::pointer,
+                      typename iterator_traits<_Iterator>::reference>
+    {
+    protected:
+      _Iterator current;
+      typedef iterator_traits<_Iterator> __traits_type;
+    public:
+      typedef _Iterator iterator_type;
+      typedef typename __traits_type::difference_type difference_type;
+      typedef typename __traits_type::pointer pointer;
+      typedef typename __traits_type::reference reference;
+      reverse_iterator() : current() { }
+      explicit
+      reverse_iterator(iterator_type __x) : current(__x) { }
+      reverse_iterator(const reverse_iterator& __x)
+      : current(__x.current) { }
+      template<typename _Iter>
+        reverse_iterator(const reverse_iterator<_Iter>& __x)
+ : current(__x.base()) { }
+      iterator_type
+      base() const
+      { return current; }
+      reference
+      operator*() const
+      {
+ _Iterator __tmp = current;
+ return *--__tmp;
+      }
+      pointer
+      operator->() const
+      { return &(operator*()); }
+      reverse_iterator&
+      operator++()
+      {
+ --current;
+ return *this;
+      }
+      reverse_iterator
+      operator++(int)
+      {
+ reverse_iterator __tmp = *this;
+ --current;
+ return __tmp;
+      }
+      reverse_iterator&
+      operator--()
+      {
+ ++current;
+ return *this;
+      }
+      reverse_iterator
+      operator--(int)
+      {
+ reverse_iterator __tmp = *this;
+ ++current;
+ return __tmp;
+      }
+      reverse_iterator
+      operator+(difference_type __n) const
+      { return reverse_iterator(current - __n); }
+      reverse_iterator&
+      operator+=(difference_type __n)
+      {
+ current -= __n;
+ return *this;
+      }
+      reverse_iterator
+      operator-(difference_type __n) const
+      { return reverse_iterator(current + __n); }
+      reverse_iterator&
+      operator-=(difference_type __n)
+      {
+ current += __n;
+ return *this;
+      }
+      reference
+      operator[](difference_type __n) const
+      { return *(*this + __n); }
+    };
+}
+
+
+
+extern "C++" {
+namespace std
+{
+  class exception
+  {
+  public:
+    exception() throw() { }
+    virtual ~exception() throw();
+    virtual const char* what() const throw();
+  };
+  class bad_exception : public exception
+  {
+  public:
+    bad_exception() throw() { }
+    virtual ~bad_exception() throw();
+    virtual const char* what() const throw();
+  };
+  typedef void (*terminate_handler) ();
+  typedef void (*unexpected_handler) ();
+  terminate_handler set_terminate(terminate_handler) throw();
+  void terminate() throw() __attribute__ ((__noreturn__));
+  unexpected_handler set_unexpected(unexpected_handler) throw();
+  void unexpected() __attribute__ ((__noreturn__));
+  bool uncaught_exception() throw() __attribute__ ((__pure__));
+}
+namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
+  void __verbose_terminate_handler();
+}
+}
+extern "C++" {
+namespace std
+{
+  class bad_alloc : public exception
+  {
+  public:
+    bad_alloc() throw() { }
+    virtual ~bad_alloc() throw();
+    virtual const char* what() const throw();
+  };
+  struct nothrow_t { };
+  extern const nothrow_t nothrow;
+  typedef void (*new_handler)();
+  new_handler set_new_handler(new_handler) throw();
+}
+
+void* operator new(std::size_t, const std::nothrow_t&) throw();
+void* operator new[](std::size_t, const std::nothrow_t&) throw();
+void operator delete(void*, const std::nothrow_t&) throw();
+void operator delete[](void*, const std::nothrow_t&) throw();
+inline void* operator new(std::size_t, void* __p) throw() { return __p; }
+inline void* operator new[](std::size_t, void* __p) throw() { return __p; }
+inline void operator delete (void*, void*) throw() { }
+inline void operator delete[](void*, void*) throw() { }
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  void
+  __throw_bad_exception(void) __attribute__((__noreturn__));
+  __attribute__((transaction_safe))
+  void
+  __throw_bad_alloc(void) __attribute__((__noreturn__));
+  void
+  __throw_bad_cast(void) __attribute__((__noreturn__));
+  void
+  __throw_bad_typeid(void) __attribute__((__noreturn__));
+  void
+  __throw_logic_error(const char*) __attribute__((__noreturn__));
+  void
+  __throw_domain_error(const char*) __attribute__((__noreturn__));
+  void
+  __throw_invalid_argument(const char*) __attribute__((__noreturn__));
+  void
+  __throw_length_error(const char*) __attribute__((__noreturn__));
+  void
+  __throw_out_of_range(const char*) __attribute__((__noreturn__));
+  void
+  __throw_runtime_error(const char*) __attribute__((__noreturn__));
+  void
+  __throw_range_error(const char*) __attribute__((__noreturn__));
+  void
+  __throw_overflow_error(const char*) __attribute__((__noreturn__));
+  void
+  __throw_underflow_error(const char*) __attribute__((__noreturn__));
+  void
+  __throw_ios_failure(const char*) __attribute__((__noreturn__));
+  void
+  __throw_system_error(int) __attribute__((__noreturn__));
+  void
+  __throw_future_error(int) __attribute__((__noreturn__));
+  void
+  __throw_bad_function_call() __attribute__((__noreturn__));
+}
+
+
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  template<typename _Tp>
+    inline void
+    swap(_Tp& __a, _Tp& __b)
+    {
+
+      _Tp __tmp = (__a);
+      __a = (__b);
+      __b = (__tmp);
+    }
+  template<typename _Tp, size_t _Nm>
+    inline void
+    swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
+    {
+      for (size_t __n = 0; __n < _Nm; ++__n)
+ swap(__a[__n], __b[__n]);
+    }
+}
+namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
+  using std::size_t;
+  using std::ptrdiff_t;
+  template<typename _Tp>
+    class new_allocator
+    {
+    public:
+      typedef size_t size_type;
+      typedef ptrdiff_t difference_type;
+      typedef _Tp* pointer;
+      typedef const _Tp* const_pointer;
+      typedef _Tp& reference;
+      typedef const _Tp& const_reference;
+      typedef _Tp value_type;
+      template<typename _Tp1>
+        struct rebind
+        { typedef new_allocator<_Tp1> other; };
+      new_allocator() throw() { }
+      new_allocator(const new_allocator&) throw() { }
+      template<typename _Tp1>
+        new_allocator(const new_allocator<_Tp1>&) throw() { }
+      ~new_allocator() throw() { }
+      pointer
+      address(reference __x) const { return &__x; }
+      const_pointer
+      address(const_reference __x) const { return &__x; }
+      __attribute__((transaction_safe))
+      pointer
+      allocate(size_type __n, const void* = 0)
+      {
+ if (__n > this->max_size())
+   std::__throw_bad_alloc();
+ return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
+      }
+__attribute__((transaction_safe))
+void
+      deallocate(pointer __p, size_type)
+      { ::operator delete(__p); }
+      size_type
+      max_size() const throw()
+      { return size_t(-1) / sizeof(_Tp); }
+      void
+      construct(pointer __p, const _Tp& __val)
+      { ::new((void *)__p) _Tp(__val); }
+      void
+      destroy(pointer __p) { __p->~_Tp(); }
+    };
+  template<typename _Tp>
+    inline bool
+    operator==(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
+    { return true; }
+  template<typename _Tp>
+    inline bool
+    operator!=(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
+    { return false; }
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  template<typename _Tp>
+    class allocator;
+  template<>
+    class allocator<void>
+    {
+    public:
+      typedef size_t size_type;
+      typedef ptrdiff_t difference_type;
+      typedef void* pointer;
+      typedef const void* const_pointer;
+      typedef void value_type;
+      template<typename _Tp1>
+        struct rebind
+        { typedef allocator<_Tp1> other; };
+    };
+  template<typename _Tp>
+    class allocator: public __gnu_cxx::new_allocator<_Tp>
+    {
+   public:
+      typedef size_t size_type;
+      typedef ptrdiff_t difference_type;
+      typedef _Tp* pointer;
+      typedef const _Tp* const_pointer;
+      typedef _Tp& reference;
+      typedef const _Tp& const_reference;
+      typedef _Tp value_type;
+      template<typename _Tp1>
+        struct rebind
+        { typedef allocator<_Tp1> other; };
+      allocator() throw() { }
+      allocator(const allocator& __a) throw()
+      : __gnu_cxx::new_allocator<_Tp>(__a) { }
+      template<typename _Tp1>
+        allocator(const allocator<_Tp1>&) throw() { }
+      ~allocator() throw() { }
+    };
+  template<typename _T1, typename _T2>
+    inline bool
+    operator==(const allocator<_T1>&, const allocator<_T2>&)
+    { return true; }
+  template<typename _Tp>
+    inline bool
+    operator==(const allocator<_Tp>&, const allocator<_Tp>&)
+    { return true; }
+  template<typename _T1, typename _T2>
+    inline bool
+    operator!=(const allocator<_T1>&, const allocator<_T2>&)
+    { return false; }
+  template<typename _Tp>
+    inline bool
+    operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
+    { return false; }
+  //extern template class allocator<char>;
+  //  extern template class allocator<wchar_t>;
+  template<typename _Alloc, bool = __is_empty(_Alloc)>
+    struct __alloc_swap
+    { static void _S_do_it(_Alloc&, _Alloc&) { } };
+  template<typename _Alloc>
+    struct __alloc_swap<_Alloc, false>
+    {
+      static void
+      _S_do_it(_Alloc& __one, _Alloc& __two)
+      {
+ if (__one != __two)
+   swap(__one, __two);
+      }
+    };
+  template<typename _Alloc, bool = __is_empty(_Alloc)>
+    struct __alloc_neq
+    {
+      static bool
+      _S_do_it(const _Alloc&, const _Alloc&)
+      { return false; }
+    };
+  template<typename _Alloc>
+    struct __alloc_neq<_Alloc, false>
+    {
+      static bool
+      _S_do_it(const _Alloc& __one, const _Alloc& __two)
+      { return __one != __two; }
+    };
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  template<typename _Arg, typename _Result>
+    struct unary_function
+    {
+      typedef _Arg argument_type;
+      typedef _Result result_type;
+    };
+  template<typename _Arg1, typename _Arg2, typename _Result>
+    struct binary_function
+    {
+      typedef _Arg1 first_argument_type;
+      typedef _Arg2 second_argument_type;
+      typedef _Result result_type;
+    };
+  template<typename _Tp>
+    struct equal_to : public binary_function<_Tp, _Tp, bool>
+    {
+      bool
+      operator()(const _Tp& __x, const _Tp& __y) const
+      { return __x == __y; }
+    };
+  template<typename _Tp>
+    struct not_equal_to : public binary_function<_Tp, _Tp, bool>
+    {
+      bool
+      operator()(const _Tp& __x, const _Tp& __y) const
+      { return __x != __y; }
+    };
+  template<typename _Tp>
+    struct greater : public binary_function<_Tp, _Tp, bool>
+    {
+      bool
+      operator()(const _Tp& __x, const _Tp& __y) const
+      { return __x > __y; }
+    };
+  template<typename _Tp>
+    struct less : public binary_function<_Tp, _Tp, bool>
+    {
+      bool
+      operator()(const _Tp& __x, const _Tp& __y) const
+      { return __x < __y; }
+    };
+  template<typename _Tp>
+    struct _Identity : public unary_function<_Tp,_Tp>
+    {
+      _Tp&
+      operator()(_Tp& __x) const
+      { return __x; }
+      const _Tp&
+      operator()(const _Tp& __x) const
+      { return __x; }
+    };
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  enum _Rb_tree_color { _S_red = false, _S_black = true };
+  struct _Rb_tree_node_base
+  {
+    typedef _Rb_tree_node_base* _Base_ptr;
+    typedef const _Rb_tree_node_base* _Const_Base_ptr;
+    _Rb_tree_color _M_color;
+    _Base_ptr _M_parent;
+    _Base_ptr _M_left;
+    _Base_ptr _M_right;
+    static _Base_ptr
+    _S_minimum(_Base_ptr __x)
+    {
+      while (__x->_M_left != 0) __x = __x->_M_left;
+      return __x;
+    }
+    static _Const_Base_ptr
+    _S_minimum(_Const_Base_ptr __x)
+    {
+      while (__x->_M_left != 0) __x = __x->_M_left;
+      return __x;
+    }
+    static _Base_ptr
+    _S_maximum(_Base_ptr __x)
+    {
+      while (__x->_M_right != 0) __x = __x->_M_right;
+      return __x;
+    }
+    static _Const_Base_ptr
+    _S_maximum(_Const_Base_ptr __x)
+    {
+      while (__x->_M_right != 0) __x = __x->_M_right;
+      return __x;
+    }
+  };
+  template<typename _Val>
+    struct _Rb_tree_node : public _Rb_tree_node_base
+    {
+      typedef _Rb_tree_node<_Val>* _Link_type;
+      _Val _M_value_field;
+    };
+  __attribute__ ((__pure__)) _Rb_tree_node_base*
+  _Rb_tree_increment(_Rb_tree_node_base* __x) throw ();
+  __attribute__ ((__pure__)) const _Rb_tree_node_base*
+  _Rb_tree_increment(const _Rb_tree_node_base* __x) throw ();
+  __attribute__ ((__pure__)) _Rb_tree_node_base*
+  _Rb_tree_decrement(_Rb_tree_node_base* __x) throw ();
+  __attribute__ ((__pure__)) const _Rb_tree_node_base*
+  _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw ();
+  template<typename _Tp>
+    struct _Rb_tree_iterator
+    {
+      typedef _Tp value_type;
+      typedef _Tp& reference;
+      typedef _Tp* pointer;
+      typedef bidirectional_iterator_tag iterator_category;
+      typedef ptrdiff_t difference_type;
+      typedef _Rb_tree_iterator<_Tp> _Self;
+      typedef _Rb_tree_node_base::_Base_ptr _Base_ptr;
+      typedef _Rb_tree_node<_Tp>* _Link_type;
+      _Rb_tree_iterator()
+      : _M_node() { }
+      explicit
+      _Rb_tree_iterator(_Link_type __x)
+      : _M_node(__x) { }
+      reference
+      operator*() const
+      { return static_cast<_Link_type>(_M_node)->_M_value_field; }
+      pointer
+      operator->() const
+      { return &static_cast<_Link_type>(_M_node)->_M_value_field; }
+      _Self&
+      operator++()
+      {
+ _M_node = _Rb_tree_increment(_M_node);
+ return *this;
+      }
+      _Self
+      operator++(int)
+      {
+ _Self __tmp = *this;
+ _M_node = _Rb_tree_increment(_M_node);
+ return __tmp;
+      }
+      _Self&
+      operator--()
+      {
+ _M_node = _Rb_tree_decrement(_M_node);
+ return *this;
+      }
+      _Self
+      operator--(int)
+      {
+ _Self __tmp = *this;
+ _M_node = _Rb_tree_decrement(_M_node);
+ return __tmp;
+      }
+      bool
+      operator==(const _Self& __x) const
+      { return _M_node == __x._M_node; }
+      bool
+      operator!=(const _Self& __x) const
+      { return _M_node != __x._M_node; }
+      _Base_ptr _M_node;
+  };
+  template<typename _Tp>
+    struct _Rb_tree_const_iterator
+    {
+      typedef _Tp value_type;
+      typedef const _Tp& reference;
+      typedef const _Tp* pointer;
+      typedef _Rb_tree_iterator<_Tp> iterator;
+      typedef bidirectional_iterator_tag iterator_category;
+      typedef ptrdiff_t difference_type;
+      typedef _Rb_tree_const_iterator<_Tp> _Self;
+      typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr;
+      typedef const _Rb_tree_node<_Tp>* _Link_type;
+      _Rb_tree_const_iterator()
+      : _M_node() { }
+      explicit
+      _Rb_tree_const_iterator(_Link_type __x)
+      : _M_node(__x) { }
+      _Rb_tree_const_iterator(const iterator& __it)
+      : _M_node(__it._M_node) { }
+      reference
+      operator*() const
+      { return static_cast<_Link_type>(_M_node)->_M_value_field; }
+      pointer
+      operator->() const
+      { return &static_cast<_Link_type>(_M_node)->_M_value_field; }
+      _Self&
+      operator++()
+      {
+ _M_node = _Rb_tree_increment(_M_node);
+ return *this;
+      }
+      _Self
+      operator++(int)
+      {
+ _Self __tmp = *this;
+ _M_node = _Rb_tree_increment(_M_node);
+ return __tmp;
+      }
+      _Self&
+      operator--()
+      {
+ _M_node = _Rb_tree_decrement(_M_node);
+ return *this;
+      }
+      _Self
+      operator--(int)
+      {
+ _Self __tmp = *this;
+ _M_node = _Rb_tree_decrement(_M_node);
+ return __tmp;
+      }
+      bool
+      operator==(const _Self& __x) const
+      { return _M_node == __x._M_node; }
+      bool
+      operator!=(const _Self& __x) const
+      { return _M_node != __x._M_node; }
+      _Base_ptr _M_node;
+    };
+  void
+  _Rb_tree_insert_and_rebalance(const bool __insert_left,
+                                _Rb_tree_node_base* __x,
+                                _Rb_tree_node_base* __p,
+                                _Rb_tree_node_base& __header) throw ();
+  _Rb_tree_node_base*
+  _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
+          _Rb_tree_node_base& __header) throw ();
+  template<typename _Key, typename _Val, typename _KeyOfValue,
+           typename _Compare, typename _Alloc = allocator<_Val> >
+    class _Rb_tree
+    {
+      typedef typename _Alloc::template rebind<_Rb_tree_node<_Val> >::other
+              _Node_allocator;
+    protected:
+      typedef _Rb_tree_node_base* _Base_ptr;
+      typedef const _Rb_tree_node_base* _Const_Base_ptr;
+    public:
+      typedef _Key key_type;
+      typedef _Val value_type;
+      typedef value_type* pointer;
+      typedef const value_type* const_pointer;
+      typedef value_type& reference;
+      typedef const value_type& const_reference;
+      typedef _Rb_tree_node<_Val>* _Link_type;
+      typedef const _Rb_tree_node<_Val>* _Const_Link_type;
+      typedef size_t size_type;
+      typedef ptrdiff_t difference_type;
+      typedef _Alloc allocator_type;
+      _Node_allocator&
+      _M_get_Node_allocator()
+      { return *static_cast<_Node_allocator*>(&this->_M_impl); }
+      const _Node_allocator&
+      _M_get_Node_allocator() const
+      { return *static_cast<const _Node_allocator*>(&this->_M_impl); }
+      allocator_type
+      get_allocator() const
+      { return allocator_type(_M_get_Node_allocator()); }
+    protected:
+      _Link_type
+      _M_get_node()
+      { return _M_impl._Node_allocator::allocate(1); }
+      __attribute__((transaction_safe))
+      void
+      _M_put_node(_Link_type __p)
+      { _M_impl._Node_allocator::deallocate(__p, 1); }
+      __attribute__((transaction_safe))
+      _Link_type
+      _M_create_node(const value_type& __x)
+      {
+ _Link_type __tmp = _M_get_node();
+ try
+   { get_allocator().construct(&__tmp->_M_value_field, __x); }
+ catch(...)
+   {
+     _M_put_node(__tmp);
+     throw;
+   }
+ return __tmp;
+      }
+      void
+      _M_destroy_node(_Link_type __p)
+      {
+ get_allocator().destroy(&__p->_M_value_field);
+ _M_put_node(__p);
+      }
+    protected:
+      template<typename _Key_compare,
+        bool _Is_pod_comparator = __is_pod(_Key_compare)>
+        struct _Rb_tree_impl : public _Node_allocator
+        {
+   _Key_compare _M_key_compare;
+   _Rb_tree_node_base _M_header;
+   size_type _M_node_count;
+   _Rb_tree_impl()
+   : _Node_allocator(), _M_key_compare(), _M_header(),
+     _M_node_count(0)
+   { _M_initialize(); }
+   _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a)
+   : _Node_allocator(__a), _M_key_compare(__comp), _M_header(),
+     _M_node_count(0)
+   { _M_initialize(); }
+ private:
+   void
+   _M_initialize()
+   {
+     this->_M_header._M_color = _S_red;
+     this->_M_header._M_parent = 0;
+     this->_M_header._M_left = &this->_M_header;
+     this->_M_header._M_right = &this->_M_header;
+   }
+ };
+      _Rb_tree_impl<_Compare> _M_impl;
+    protected:
+      _Base_ptr&
+      _M_root()
+      { return this->_M_impl._M_header._M_parent; }
+      _Const_Base_ptr
+      _M_root() const
+      { return this->_M_impl._M_header._M_parent; }
+      _Base_ptr&
+      _M_leftmost()
+      { return this->_M_impl._M_header._M_left; }
+      _Const_Base_ptr
+      _M_leftmost() const
+      { return this->_M_impl._M_header._M_left; }
+      _Base_ptr&
+      _M_rightmost()
+      { return this->_M_impl._M_header._M_right; }
+      _Const_Base_ptr
+      _M_rightmost() const
+      { return this->_M_impl._M_header._M_right; }
+      _Link_type
+      _M_begin()
+ { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); }
+      _Const_Link_type
+      _M_begin() const
+      {
+ return static_cast<_Const_Link_type>
+   (this->_M_impl._M_header._M_parent);
+      }
+      _Link_type
+      _M_end()
+      { return static_cast<_Link_type>(&this->_M_impl._M_header); }
+      _Const_Link_type
+      _M_end() const
+      { return static_cast<_Const_Link_type>(&this->_M_impl._M_header); }
+      static const_reference
+      _S_value(_Const_Link_type __x)
+      { return __x->_M_value_field; }
+      static const _Key&
+      _S_key(_Const_Link_type __x)
+      { return _KeyOfValue()(_S_value(__x)); }
+      static _Link_type
+      _S_left(_Base_ptr __x)
+      { return static_cast<_Link_type>(__x->_M_left); }
+      static _Const_Link_type
+      _S_left(_Const_Base_ptr __x)
+      { return static_cast<_Const_Link_type>(__x->_M_left); }
+      static _Link_type
+      _S_right(_Base_ptr __x)
+      { return static_cast<_Link_type>(__x->_M_right); }
+      static _Const_Link_type
+      _S_right(_Const_Base_ptr __x)
+      { return static_cast<_Const_Link_type>(__x->_M_right); }
+      static const_reference
+      _S_value(_Const_Base_ptr __x)
+      { return static_cast<_Const_Link_type>(__x)->_M_value_field; }
+      static const _Key&
+      _S_key(_Const_Base_ptr __x)
+      { return _KeyOfValue()(_S_value(__x)); }
+    public:
+      typedef _Rb_tree_iterator<value_type> iterator;
+      typedef _Rb_tree_const_iterator<value_type> const_iterator;
+      typedef std::reverse_iterator<iterator> reverse_iterator;
+      typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+    private:
+      iterator
+      _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y,
+   const value_type& __v);
+    public:
+      _Rb_tree() { }
+      iterator
+      begin()
+      {
+ return iterator(static_cast<_Link_type>
+   (this->_M_impl._M_header._M_left));
+      }
+      const_iterator
+      begin() const
+      {
+ return const_iterator(static_cast<_Const_Link_type>
+         (this->_M_impl._M_header._M_left));
+      }
+      iterator
+      end()
+ { return iterator(static_cast<_Link_type>(&this->_M_impl._M_header)); }
+      const_iterator
+      end() const
+      {
+ return const_iterator(static_cast<_Const_Link_type>
+         (&this->_M_impl._M_header));
+      }
+      pair<iterator, bool>
+      _M_insert_unique(const value_type& __x);
+    };
+  template<typename _Key, typename _Val, typename _KeyOfValue,
+           typename _Compare, typename _Alloc>
+    typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
+    _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
+    _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, const _Val& __v)
+    {
+      _Link_type __z = _M_create_node(__v);
+      return iterator(__z);
+    }
+  template<typename _Key, typename _Val, typename _KeyOfValue,
+           typename _Compare, typename _Alloc>
+    pair<typename _Rb_tree<_Key, _Val, _KeyOfValue,
+      _Compare, _Alloc>::iterator, bool>
+    _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
+    _M_insert_unique(const _Val& __v)
+    {
+      _Link_type __x = _M_begin();
+      _Link_type __y = _M_end();
+      iterator __j = iterator(__y);
+ return pair<iterator, bool>(_M_insert_(__x, __y, __v), true);
+    }
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+  template<typename _Key, typename _Compare = std::less<_Key>,
+    typename _Alloc = std::allocator<_Key> >
+    class set
+    {
+    public:
+      typedef _Key key_type;
+      typedef _Key value_type;
+      typedef _Compare key_compare;
+      typedef _Compare value_compare;
+      typedef _Alloc allocator_type;
+    private:
+ typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
+      typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
+         key_compare, _Key_alloc_type> _Rep_type;
+      _Rep_type _M_t;
+    public:
+      typedef typename _Key_alloc_type::pointer pointer;
+      typedef typename _Key_alloc_type::const_pointer const_pointer;
+      typedef typename _Key_alloc_type::reference reference;
+      typedef typename _Key_alloc_type::const_reference const_reference;
+      typedef typename _Rep_type::const_iterator iterator;
+      typedef typename _Rep_type::const_iterator const_iterator;
+      typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
+ typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
+      typedef typename _Rep_type::size_type size_type;
+      typedef typename _Rep_type::difference_type difference_type;
+      std::pair<iterator, bool>
+      insert(const value_type& __x)
+      {
+   _M_t._M_insert_unique(__x);
+      }
+    };
+}
+__attribute__((transaction_pure))
+void* operator new(size_t);
+__attribute__((transaction_pure))
+void operator delete(void*);
+class Widget
+{
+private:
+};
+class Screen
+{
+protected:
+std::set<Widget *> widgets;
+public:
+void addWidget(Widget* widget);
+};
+void Screen::addWidget(Widget* widget)
+{
+widgets.insert(widget);
+}
Index: gcc/testsuite/g++.dg/tm/pr47573.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr47573.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr47573.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,25 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+template<typename _Tp> class allocator
+{
+        public:
+        allocator() { }
+};
+extern template class allocator<char>;
+
+template<typename _Alloc = allocator<char> > class basic_string
+{
+        public:
+        _Alloc _M_dataplus;
+
+        __attribute__((transaction_safe))
+        basic_string() : _M_dataplus(_Alloc())
+        {
+        }
+};
+
+int getStringHeight()
+{
+        basic_string<> tmp;
+}
Index: gcc/testsuite/g++.dg/tm/pr46269.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr46269.C   (.../trunk)     (revision 0)
+++ gcc/testsuite/g++.dg/tm/pr46269.C (.../branches/transactional-memory) (revision 180773)
@@ -0,0 +1,29 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+static inline void atomic_exchange_and_add()
+{
+  __asm__  ("");
+}
+
+template<class T> class shared_ptr
+{
+public:
+  shared_ptr( T * p )
+  {
+    atomic_exchange_and_add();
+  }
+};
+
+class BuildingCompletedEvent
+{
+  public:
+  __attribute__((transaction_callable)) void updateBuildingSite(void);
+  __attribute__((transaction_pure)) BuildingCompletedEvent();
+};
+
+void BuildingCompletedEvent::updateBuildingSite(void)
+{
+  shared_ptr<BuildingCompletedEvent> event(new BuildingCompletedEvent());
+}
+

Reply via email to