When running the testsuite with clang, gdb.linespec/cpls-ops.cc
fails to compile with the following errors:
warning: 'operator new' should not return a null pointer unless
it is declared 'throw()' or 'noexcept' [-Wnew-returns-null]
warning: 'operator new[]' should not return a null pointer unless
it is declared 'throw()' or 'noexcept' [-Wnew-returns-null]
This prevents the gdb.linespec/cpls-ops.exp testcase from executing.
This commit fixes.
gdb/testsuite/ChangeLog:
* gdb.linespec/cpls-ops.cc (dummy): New static global.
(test_op_new::operator new): Add return statement.
(test_op_new_array::operator new[]): Likewise.
+2020-05-28 Gary Benson <gbenson@redhat.com>
+
+ * gdb.linespec/cpls-ops.cc (dummy): New static global.
+ (test_op_new::operator new): Add return statement.
+ (test_op_new_array::operator new[]): Likewise.
+
2020-05-27 Pedro Alves <palves@redhat.com>
* gdb.linespec/cp-completion-aliases.exp: Remove readline_is_used
/* Code for operator new tests. */
+static int dummy;
+
struct test_op_new
{
void *operator new (size_t);
void *
test_op_new::operator new (size_t)
{
- return NULL;
+ return &dummy;
}
/* Code for operator delete tests. */
void *
test_op_new_array::operator new[] (size_t)
{
- return NULL;
+ return &dummy;
}
/* Code for operator delete[] tests. */