[2/3] Add noexcept to custom non-throwing new operators.

Message ID 20161123200652.89209-3-jhb@FreeBSD.org
State New, archived
Headers

Commit Message

John Baldwin Nov. 23, 2016, 8:06 p.m. UTC
  Both libc++ and libstdc++ declare non-throwing new operators as
noexcept and overloads must also be noexcept.  This fixes a
-Wmissing-exception-spec warning with clang.

gdb/ChangeLog:

	* common/new-op.c (operator new): Mark 'noexcept'.
	(operator new[]): Likewise.
---
 gdb/ChangeLog       | 5 +++++
 gdb/common/new-op.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)
  

Comments

Pedro Alves Nov. 24, 2016, 5:03 p.m. UTC | #1
On 11/23/2016 08:06 PM, John Baldwin wrote:
> Both libc++ and libstdc++ declare non-throwing new operators as
> noexcept and overloads must also be noexcept.  This fixes a
> -Wmissing-exception-spec warning with clang.
> 
> gdb/ChangeLog:
> 
> 	* common/new-op.c (operator new): Mark 'noexcept'.
> 	(operator new[]): Likewise.

OK.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9e8fb4f..051d4ce 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@ 
 2016-11-23  John Baldwin  <jhb@FreeBSD.org>
 
+	* common/new-op.c (operator new): Mark 'noexcept'.
+	(operator new[]): Likewise.
+
+2016-11-23  John Baldwin  <jhb@FreeBSD.org>
+
 	* breakpoint.h (class number_or_range_parser): Use 'class' instead of
 	'struct'.
 	* mi/mi-main.c (mi_cmd_trace_frame_collected): Use
diff --git a/gdb/common/new-op.c b/gdb/common/new-op.c
index 1eb4f94..c67239c 100644
--- a/gdb/common/new-op.c
+++ b/gdb/common/new-op.c
@@ -76,7 +76,7 @@  operator new (std::size_t sz)
 }
 
 void *
-operator new (std::size_t sz, const std::nothrow_t&)
+operator new (std::size_t sz, const std::nothrow_t&) noexcept
 {
   /* malloc (0) is unpredictable; avoid it.  */
   if (sz == 0)
@@ -91,7 +91,7 @@  operator new[] (std::size_t sz)
 }
 
 void*
-operator new[] (std::size_t sz, const std::nothrow_t&)
+operator new[] (std::size_t sz, const std::nothrow_t&) noexcept
 {
   return ::operator new (sz, std::nothrow);
 }