]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/util/replacement_memory_operators.h
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / replacement_memory_operators.h
index 895ccfe389705114b77d23e51244ef73f469cbdb..a90ffd475245ae33ae7275176c2af363d777adb1 100644 (file)
@@ -1,5 +1,5 @@
 //
-// Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2007-2020 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -20,6 +20,7 @@
 #include <stdexcept>
 #include <cstdlib>
 #include <cstdio>
+#include <testsuite_hooks.h>
 
 namespace __gnu_test
 {
@@ -31,8 +32,8 @@ namespace __gnu_test
     bool       _M_throw;
 
     counter() : _M_count(0), _M_throw(true) { }
-    
-    ~counter()
+
+    ~counter() THROW (counter_error)
     {
       if (_M_throw && _M_count != 0)
        throw counter_error();
@@ -45,12 +46,12 @@ namespace __gnu_test
     decrement() { get()._M_count--; }
 
     static counter&
-    get() 
+    get()
     {
       static counter g;
       return g;
     }
-  
+
     static std::size_t
     count() { return get()._M_count; }
 
@@ -59,11 +60,11 @@ namespace __gnu_test
   };
 
   template<typename Alloc, bool uses_global_new>
-    bool 
+    bool
     check_new(Alloc a = Alloc())
     {
       __gnu_test::counter::exceptions(false);
-      a.allocate(10);
+      (void) a.allocate(10);
       const bool __b((__gnu_test::counter::count() > 0) == uses_global_new);
       if (!__b)
        throw std::logic_error("counter not incremented");
@@ -71,11 +72,15 @@ namespace __gnu_test
     }
 
   template<typename Alloc, bool uses_global_delete>
-    bool 
+    bool
     check_delete(Alloc a = Alloc())
     {
       __gnu_test::counter::exceptions(false);
+#if __cplusplus >= 201103L
+      auto p = a.allocate(10);
+#else
       typename Alloc::pointer p = a.allocate(10);
+#endif
       const std::size_t count1 = __gnu_test::counter::count();
       a.deallocate(p, 10);
       const std::size_t count2 = __gnu_test::counter::count();
@@ -86,7 +91,7 @@ namespace __gnu_test
     }
 } // namespace __gnu_test
 
-void* operator new(std::size_t size) throw(std::bad_alloc)
+void* operator new(std::size_t size) THROW(std::bad_alloc)
 {
   std::printf("operator new is called \n");
   void* p = std::malloc(size);
@@ -95,7 +100,7 @@ void* operator new(std::size_t size) throw(std::bad_alloc)
   __gnu_test::counter::increment();
   return p;
 }
+
 void operator delete(void* p) throw()
 {
   std::printf("operator delete is called \n");
@@ -104,10 +109,10 @@ void operator delete(void* p) throw()
       std::free(p);
       __gnu_test::counter::decrement();
 
-      std::size_t count = __gnu_test::counter::count(); 
+      std::size_t count = __gnu_test::counter::count();
       if (count == 0)
        std::printf("All memory released \n");
       else
-       std::printf("%lu allocations to be released \n", count);
+       std::printf("%lu allocations to be released \n", (unsigned long)count);
     }
 }