Hi!

On 2025-02-17T16:40:05+0000, "shynur ." <one.last.k...@outlook.com> wrote:
>> As part of the Git commit message, please include a ChangeLog update (see
>> <https://gcc.gnu.org/codingconventions.html#ChangeLogs> and 'git log').
>
> I've written a new patch which is attached.

Pushed to trunk branch commit e759ff08e2e2e7128db7e6313b4218daa367c74f
"libgomp: Add '__attribute__((unused))' to variables used only in 
'assert(...)'",
see attached.  The only change is that I've added a "libgomp:" prefix to
the title line of the Git commit log.  Thanks!


Grüße
 Thomas


>From e759ff08e2e2e7128db7e6313b4218daa367c74f Mon Sep 17 00:00:00 2001
From: shynur <shy...@outlook.com>
Date: Mon, 17 Feb 2025 23:06:58 +0800
Subject: [PATCH] libgomp: Add '__attribute__((unused))' to variables used only
 in 'assert(...)'

Without this attribute, the building process will fail if GCC is configured
with 'CFLAGS=-DNDEBUG'.

libgomp/ChangeLog:

	* oacc-mem.c (acc_unmap_data, goacc_exit_datum_1, find_group_last,
	goacc_enter_data_internal): Add '__attribute__((unused))'.
	* target.c (gomp_unmap_vars_internal): Likewise.
---
 libgomp/oacc-mem.c | 9 +++++----
 libgomp/target.c   | 5 +++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c
index c75471bc2be..718252b44ba 100644
--- a/libgomp/oacc-mem.c
+++ b/libgomp/oacc-mem.c
@@ -480,7 +480,7 @@ acc_unmap_data (void *h)
   tgt->tgt_end = 0;
   tgt->to_free = NULL;
 
-  bool is_tgt_unmapped = gomp_remove_var (acc_dev, n);
+  bool is_tgt_unmapped __attribute__((unused)) = gomp_remove_var (acc_dev, n);
   assert (is_tgt_unmapped);
 
   gomp_mutex_unlock (&acc_dev->lock);
@@ -743,7 +743,8 @@ goacc_exit_datum_1 (struct gomp_device_descr *acc_dev, void *h, size_t s,
 	    if (n->tgt->list[l_i].key
 		&& !n->tgt->list[l_i].is_attach)
 	      ++num_mappings;
-	  bool is_tgt_unmapped = gomp_remove_var (acc_dev, n);
+	  bool is_tgt_unmapped __attribute__((unused))
+	    = gomp_remove_var (acc_dev, n);
 	  assert (is_tgt_unmapped || num_mappings > 1);
 	}
     }
@@ -1023,7 +1024,7 @@ static int
 find_group_last (int pos, size_t mapnum, size_t *sizes, unsigned short *kinds)
 {
   unsigned char kind0 = kinds[pos] & 0xff;
-  int first_pos = pos;
+  int first_pos __attribute__((unused)) = pos;
 
   switch (kind0)
     {
@@ -1203,7 +1204,7 @@ goacc_enter_data_internal (struct gomp_device_descr *acc_dev, size_t mapnum,
 	      /* Let 'goacc_map_vars' -> 'gomp_map_vars_internal' handle
 		 this.  */
 	      gomp_mutex_unlock (&acc_dev->lock);
-	      struct target_mem_desc *tgt_
+	      struct target_mem_desc *tgt_ __attribute__((unused))
 		= goacc_map_vars (acc_dev, aq, groupnum, &hostaddrs[i], NULL,
 				  &sizes[i], &kinds[i], true,
 				  GOMP_MAP_VARS_ENTER_DATA);
diff --git a/libgomp/target.c b/libgomp/target.c
index 9fc51b160f0..dbc4535b96f 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -2092,8 +2092,9 @@ gomp_unmap_vars_internal (struct target_mem_desc *tgt, bool do_copyfrom,
 			    tgt->list[i].length);
       if (do_remove)
 	{
-	  struct target_mem_desc *k_tgt = k->tgt;
-	  bool is_tgt_unmapped = gomp_remove_var (devicep, k);
+	  struct target_mem_desc *k_tgt __attribute__((unused)) = k->tgt;
+	  bool is_tgt_unmapped __attribute__((unused))
+	    = gomp_remove_var (devicep, k);
 	  /* It would be bad if TGT got unmapped while we're still iterating
 	     over its LIST_COUNT, and also expect to use it in the following
 	     code.  */
-- 
2.34.1

Reply via email to