From 9c621549249350b78860b277e610a34600e25bc2 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 12 Oct 2025 22:23:24 +0100 Subject: [PATCH] Fix some new compiler warnings seen when using GCC 15 and clang 21. No functional changes. --- tgt-vhdl/vhdl_element.cc | 10 +++++----- vhdlpp/main.cc | 6 +++--- vhdlpp/vtype.cc | 5 +++-- vpi/v2009_string.c | 2 +- vpi/vhdl_table.c | 9 +++++---- vpi_user.h | 4 ++-- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tgt-vhdl/vhdl_element.cc b/tgt-vhdl/vhdl_element.cc index 7aa7e4298..cc3dc1021 100644 --- a/tgt-vhdl/vhdl_element.cc +++ b/tgt-vhdl/vhdl_element.cc @@ -1,7 +1,7 @@ /* * VHDL abstract syntax elements. * - * Copyright (C) 2008-2021 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2025 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -127,10 +127,7 @@ void* vhdl_element::operator new(size_t size) // to NULL (since it's safe to delete a NULL pointer). void vhdl_element::operator delete(void* ptr) { - // Let the default delete handle the deallocation - ::operator delete(ptr); - - // Remember that we've already deleted this pointer so we don't + // Remember that we've deleted this pointer so we don't // delete it again in the call to free_all_objects vector::iterator it = find(allocated_.begin(), allocated_.end(), static_cast(ptr)); @@ -144,6 +141,9 @@ void vhdl_element::operator delete(void* ptr) cerr << "??? vhdl_element::operator delete called on an object not " << "allocated by vhdl_element::operator new" << endl; } + + // Let the default delete handle the deallocation + ::operator delete(ptr); } // Return the total number of bytes our custom operator new has seen. diff --git a/vhdlpp/main.cc b/vhdlpp/main.cc index ca1f18132..36ee8f232 100644 --- a/vhdlpp/main.cc +++ b/vhdlpp/main.cc @@ -1,6 +1,6 @@ const char COPYRIGHT[] = - "Copyright (c) 2011-2024 Stephen Williams (steve@icarus.com)\n" + "Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com)\n" "Copyright CERN 2012 / Stephen Williams (steve@icarus.com)"; /* * This source code is free software; you can redistribute it @@ -22,8 +22,6 @@ const char COPYRIGHT[] = # include "version_base.h" # include "version_tag.h" -using namespace std; - /* * Usage: vhdlpp [flags] sourcefile... * Flags: @@ -100,6 +98,8 @@ const char NOTICE[] = # define mkdir(path, mode) mkdir(path) #endif +using namespace std; + bool verbose_flag = false; // Where to dump design entities diff --git a/vhdlpp/vtype.cc b/vhdlpp/vtype.cc index d52d2e933..fbca95623 100644 --- a/vhdlpp/vtype.cc +++ b/vhdlpp/vtype.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -23,6 +23,7 @@ # include # include # include +# include # include using namespace std; @@ -217,7 +218,7 @@ int VTypeArray::get_width(ScopeBase*scope) const if(!dim.lsb()->evaluate(scope, lsb_val)) return -1; - size *= 1 + labs(msb_val - lsb_val); + size *= 1 + abs(msb_val - lsb_val); } return element_type()->get_width(scope) * size; diff --git a/vpi/v2009_string.c b/vpi/v2009_string.c index 2ea4cad93..71741da43 100644 --- a/vpi/v2009_string.c +++ b/vpi/v2009_string.c @@ -270,7 +270,7 @@ static PLI_INT32 atohex_calltf(ICARUS_VPI_CONST PLI_BYTE8*name) */ static void value_to_text_base(char*text, long val, long base) { - static const char digit_map[16] = "0123456789abcdef"; + static const char digit_map[16] __attribute__ ((nonstring)) = "0123456789abcdef"; char* ptr; assert(base <= 16); diff --git a/vpi/vhdl_table.c b/vpi/vhdl_table.c index eea79a559..3f9f5df62 100644 --- a/vpi/vhdl_table.c +++ b/vpi/vhdl_table.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -20,6 +20,7 @@ # include "vpi_config.h" # include "vpi_user.h" # include +# include # include "ivl_alloc.h" # include "sys_priv.h" @@ -93,7 +94,7 @@ static PLI_INT32 monitor_events(struct t_cb_data*cb) static PLI_INT32 ivlh_attribute_event_compiletf(ICARUS_VPI_CONST PLI_BYTE8*data) { - event_type_t type = (event_type_t) data; + event_type_t type = (event_type_t)(uintptr_t)data; vpiHandle sys = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, sys); vpiHandle arg; @@ -153,7 +154,7 @@ static PLI_INT32 ivlh_attribute_event_compiletf(ICARUS_VPI_CONST PLI_BYTE8*data) static PLI_INT32 ivlh_attribute_event_calltf(ICARUS_VPI_CONST PLI_BYTE8*data) { - event_type_t type = (event_type_t) data; + event_type_t type = (event_type_t)(uintptr_t)data; vpiHandle sys = vpi_handle(vpiSysTfCall, 0); struct t_vpi_value rval; struct monitor_data*mon; @@ -198,7 +199,7 @@ static PLI_INT32 ivlh_attribute_event_sizetf(ICARUS_VPI_CONST PLI_BYTE8*type) static PLI_INT32 ivlh_shift_calltf(ICARUS_VPI_CONST PLI_BYTE8*data) { - shift_type_t shift_type = (shift_type_t) data; + shift_type_t shift_type = (shift_type_t)(uintptr_t)data; vpiHandle callh = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, callh); vpiHandle argh = vpi_scan(argv); diff --git a/vpi_user.h b/vpi_user.h index be869a784..bad846192 100644 --- a/vpi_user.h +++ b/vpi_user.h @@ -428,13 +428,13 @@ extern PLI_UINT32 vpi_mcd_open(char *name); extern PLI_UINT32 vpi_mcd_close(PLI_UINT32 mcd); extern char *vpi_mcd_name(PLI_UINT32 mcd); extern PLI_INT32 vpi_mcd_printf(PLI_UINT32 mcd, const char*fmt, ...) -#ifdef __MINGW32__ +#if defined(__MINGW32__) && !defined(__clang__) __attribute__((format (gnu_printf,2,3))); #else __attribute__((format (printf,2,3))); #endif extern PLI_INT32 vpi_printf(const char*fmt, ...) -#ifdef __MINGW32__ +#if defined(__MINGW32__) && !defined(__clang__) __attribute__((format (gnu_printf,1,2))); #else __attribute__((format (printf,1,2)));