[PR,gdb/31328] gdb: Fix building with clang

Message ID 20240205165005.3861316-1-jremus@linux.ibm.com
State New
Headers
Series [PR,gdb/31328] gdb: Fix building with clang |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Jens Remus Feb. 5, 2024, 4:50 p.m. UTC
  This resolves the following clang++ error message:

../../gdb/symtab.c:4892:33: error: logical not is only applied to the left hand side of this comparison [-Werror,-Wlogical-not-parentheses]
              if (preg.has_value () && !preg->exec (sym->natural_name (), 0,
                                       ^
../../gdb/symtab.c:4892:33: note: add parentheses after the '!' to evaluate the comparison first
              if (preg.has_value () && !preg->exec (sym->natural_name (), 0,
                                       ^
                                        (
../../gdb/symtab.c:4892:33: note: add parentheses around left hand side expression to silence this warning
              if (preg.has_value () && !preg->exec (sym->natural_name (), 0,
                                       ^
                                       (

Bug: https://sourceware.org/PR31328

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
 gdb/symtab.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Tom Tromey Feb. 5, 2024, 5:50 p.m. UTC | #1
>>>>> Jens Remus <jremus@linux.ibm.com> writes:

> This resolves the following clang++ error message:
[...]

Thank you.  This is ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  
Andreas Arnez Feb. 8, 2024, 1:23 p.m. UTC | #2
On Mon, Feb 05 2024, Tom Tromey wrote:

>>>>>> Jens Remus <jremus@linux.ibm.com> writes:
>
>> This resolves the following clang++ error message:
> [...]
>
> Thank you.  This is ok.
> Approved-By: Tom Tromey <tom@tromey.com>
>
> Tom

Thanks, pushed.

--
Andreas
  

Patch

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 32b19e6c9023..02f5d4f1b3d1 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4889,8 +4889,8 @@  global_symbol_searcher::add_matching_symbols
 	      if (!sym->matches (kind))
 		continue;
 
-	      if (preg.has_value () && !preg->exec (sym->natural_name (), 0,
-						    nullptr, 0) == 0)
+	      if (preg.has_value () && preg->exec (sym->natural_name (), 0,
+						   nullptr, 0) != 0)
 		continue;
 
 	      if (((sym->domain () == VAR_DOMAIN