Re: git: 75a24e7f9afb - main - ctld: Disable -Wshadow for GCC
- In reply to: John Baldwin : "git: 75a24e7f9afb - main - ctld: Disable -Wshadow for GCC"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 11 Apr 2025 13:56:22 UTC
On 4/11/25 09:52, John Baldwin wrote: > The branch main has been updated by jhb: > > URL: https://cgit.FreeBSD.org/src/commit/?id=75a24e7f9afb128138c3b3462b80731cab0f5bdd > > commit 75a24e7f9afb128138c3b3462b80731cab0f5bdd > Author: John Baldwin <jhb@FreeBSD.org> > AuthorDate: 2025-04-11 13:34:36 +0000 > Commit: John Baldwin <jhb@FreeBSD.org> > CommitDate: 2025-04-11 13:52:39 +0000 > > ctld: Disable -Wshadow for GCC > > GCC raises shadow warnings in C++ when a global function shadows a > structure type name (since it shadows the constructors for that type). > System headers are full of such cases (and some such as struct sigaction > vs sigaction() are mandated by POSIX), so just disable the warning. > > For example: > > In file included from usr.sbin/ctld/ctld.cc:33: > sys/sys/event.h:366:20: error: 'int kqueue()' hides constructor for 'struct kqueue' [-Werror=shadow] > 366 | int kqueue(void); > | ^ > sys/sys/event.h:371:43: error: 'int kevent(int, const kevent*, int, kevent*, int, const timespec*)' hides constructor for 'struct kevent' [-Werror=shadow] > 371 | const struct timespec *timeout); > | ^ > In file included from usr.sbin/ctld/ctld.cc:37: > sys/sys/stat.h:396:63: error: 'int stat(const char*, stat*)' hides constructor for 'struct stat' [-Werror=shadow] > 396 | int stat(const char * __restrict, struct stat * __restrict); > | ^ > > Reported by: bz > --- > usr.sbin/ctld/Makefile | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/usr.sbin/ctld/Makefile b/usr.sbin/ctld/Makefile > index f96f3152e061..79c69c95fbb1 100644 > --- a/usr.sbin/ctld/Makefile > +++ b/usr.sbin/ctld/Makefile > @@ -14,6 +14,7 @@ CFLAGS+= -I${SRCTOP}/sys/dev/iscsi > CFLAGS+= -I${SRCTOP}/lib/libiscsiutil > #CFLAGS+= -DICL_KERNEL_PROXY > NO_WCAST_ALIGN= > +CXXWARNFLAGS.gcc= -Wno-shadow > MAN= ctld.8 ctl.conf.5 > > LIBADD= bsdxml iscsiutil md sbuf util ucl m nv Possibly we should disable -Wshadow globally for GCC for C++ in bsd.sys.mk. -- John Baldwin