gdb/location.c: fix build on gcc-12 (NULL comparison)

Message ID 20211114173112.2760887-1-slyfox@gentoo.org
State New
Headers show
Series
  • gdb/location.c: fix build on gcc-12 (NULL comparison)
Related show

Commit Message

Mike Frysinger via Binutils Nov. 14, 2021, 5:31 p.m.
From: Sergei Trofimovich <siarheit@google.com>


On gcc-12 build fails as:

    gdb/location.c: In function 'int event_location_empty_p(const event_location*)':
    gdb/location.c:963:38: error: the address of 'event_location::<unnamed union>::explicit_loc' will never be NULL [-Werror=address]
      963 |       return (EL_EXPLICIT (location) == NULL
          |                                      ^

EL_EXPLICIT returns address to struct field within 'location'.
It can never be NULL.
---
 gdb/location.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.33.1

Patch

diff --git a/gdb/location.c b/gdb/location.c
index 827294e106a..cda54e14df5 100644
--- a/gdb/location.c
+++ b/gdb/location.c
@@ -960,12 +960,11 @@  event_location_empty_p (const struct event_location *location)
       return 0;
 
     case EXPLICIT_LOCATION:
-      return (EL_EXPLICIT (location) == NULL
-	      || (EL_EXPLICIT (location)->source_filename == NULL
-		  && EL_EXPLICIT (location)->function_name == NULL
-		  && EL_EXPLICIT (location)->label_name == NULL
-		  && (EL_EXPLICIT (location)->line_offset.sign
-		      == LINE_OFFSET_UNKNOWN)));
+      return (EL_EXPLICIT (location)->source_filename == NULL
+	      && EL_EXPLICIT (location)->function_name == NULL
+	      && EL_EXPLICIT (location)->label_name == NULL
+	      && (EL_EXPLICIT (location)->line_offset.sign
+	          == LINE_OFFSET_UNKNOWN));
 
     case PROBE_LOCATION:
       return EL_PROBE (location) == NULL;