Skip to content

Commit

Permalink
Add the Clang specific -Wmissing-variable-declarations to WARNS=6.
Browse files Browse the repository at this point in the history
This compiler flag enforces that that people either mark variables
static or use an external declarations for the variable, similar to how
-Wmissing-prototypes works for functions.

Due to the fact that Yacc/Lex generate code that cannot trivially be
changed to not warn because of this (lots of yy* variables), add a
NO_WMISSING_VARIABLE_DECLARATIONS that can be used to turn off this
specific compiler warning.

Announced on:	toolchain@
  • Loading branch information
ed authored and ed committed Apr 19, 2013
1 parent e342f91 commit 1201257
Show file tree
Hide file tree
Showing 21 changed files with 40 additions and 2 deletions.
2 changes: 2 additions & 0 deletions bin/expr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ PROG= expr
SRCS= expr.y
YFLAGS=

NO_WMISSING_VARIABLE_DECLARATIONS=

.include <bsd.prog.mk>
2 changes: 2 additions & 0 deletions lib/csu/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ SSP_CFLAGS=

SED_FIX_NOTE = -i "" -e '/\.note\.tag/s/progbits/note/'

NO_WMISSING_VARIABLE_DECLARATIONS=

.include "../Makefile.inc"
1 change: 1 addition & 0 deletions sbin/gbde/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SRCS+= g_bde_lock.c
# rijndael-fst.c does evil casting things which can results in warnings,
# the test-vectors check out however, so it works right.
NO_WCAST_ALIGN=
NO_WMISSING_VARIABLE_DECLARATIONS=

CFLAGS+= -I${.CURDIR}/../../sys
.PATH: ${.CURDIR}/../../sys/geom/bde \
Expand Down
2 changes: 2 additions & 0 deletions sbin/geom/class/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ LINKS= ${BINDIR}/geom ${BINDIR}/g${GEOM_CLASS}
MAN= g${GEOM_CLASS}.8
SRCS+= geom_${GEOM_CLASS}.c subr.c

NO_WMISSING_VARIABLE_DECLARATIONS=

CFLAGS+= -I${.CURDIR}/../..

.include "../Makefile.inc"
1 change: 1 addition & 0 deletions sbin/hastctl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ MAN= hastctl.8

NO_WFORMAT=
NO_WCAST_ALIGN=
NO_WMISSING_VARIABLE_DECLARATIONS=
CFLAGS+=-I${.CURDIR}/../hastd
CFLAGS+=-DHAVE_CAPSICUM
CFLAGS+=-DINET
Expand Down
1 change: 1 addition & 0 deletions sbin/hastd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ MAN= hastd.8 hast.conf.5

NO_WFORMAT=
NO_WCAST_ALIGN=
NO_WMISSING_VARIABLE_DECLARATIONS=
CFLAGS+=-I${.CURDIR}
CFLAGS+=-DHAVE_CAPSICUM
CFLAGS+=-DPROTO_TCP_DEFAULT_PORT=8457
Expand Down
1 change: 1 addition & 0 deletions sbin/md5/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MLINKS= md5.1 rmd160.1 \
md5.1 sha256.1 \
md5.1 sha512.1

NO_WMISSING_VARIABLE_DECLARATIONS=
WFORMAT?= 1

DPADD= ${LIBMD}
Expand Down
4 changes: 4 additions & 0 deletions share/mk/bsd.sys.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ CWARNFLAGS+= -Wcast-align
.if ${WARNS} >= 6
CWARNFLAGS+= -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls\
-Wold-style-definition
.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) && \
!defined(NO_WMISSING_VARIABLE_DECLARATIONS)
CWARNFLAGS+= -Wmissing-variable-declarations
.endif
.endif # WARNS >= 6
.if ${WARNS} >= 2 && ${WARNS} <= 4
# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
Expand Down
2 changes: 2 additions & 0 deletions usr.bin/ar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h
DPADD= ${LIBARCHIVE} ${LIBELF} ${LIBZ}
LDADD= -larchive -lelf -lz

NO_WMISSING_VARIABLE_DECLARATIONS=

CFLAGS+=-I. -I${.CURDIR}

.if ${MK_SHARED_TOOLCHAIN} == "no"
Expand Down
2 changes: 2 additions & 0 deletions usr.bin/bc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ CFLAGS+= -I. -I${.CURDIR}
DPADD= ${LIBEDIT} ${LIBTERMCAP}
LDADD= -ledit -ltermcap

NO_WMISSING_VARIABLE_DECLARATIONS=

FILES+= bc.library
FILESDIR=${SHAREDIR}/misc

Expand Down
2 changes: 2 additions & 0 deletions usr.bin/bzip2recover/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ BZ2DIR= ${.CURDIR}/../../contrib/bzip2
PROG= bzip2recover
NO_MAN=

NO_WMISSING_VARIABLE_DECLARATIONS=

.include <bsd.prog.mk>
2 changes: 2 additions & 0 deletions usr.bin/find/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ SRCS= find.c function.c ls.c main.c misc.c operator.c option.c \
getdate.y
YFLAGS=

NO_WMISSING_VARIABLE_DECLARATIONS=

.include <bsd.prog.mk>
3 changes: 3 additions & 0 deletions usr.bin/indent/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
# $FreeBSD$

PROG= indent
SRCS= indent.c io.c lexi.c parse.c pr_comment.c args.c

NO_WMISSING_VARIABLE_DECLARATIONS=

.include <bsd.prog.mk>
4 changes: 2 additions & 2 deletions usr.bin/m4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ PROG= m4
CFLAGS+=-DEXTENDED -I${.CURDIR} -I${.CURDIR}/lib
DPADD= ${LIBY} ${LIBL} ${LIBM}
LDADD= -ly -ll -lm
# clang needs 1 while with gcc we can use 2
#WARNS= 1

NO_WMISSING_VARIABLE_DECLARATIONS=

SRCS= eval.c expr.c look.c main.c misc.c gnum4.c trace.c parser.y tokenizer.l
.PATH: ${.CURDIR}/lib
Expand Down
2 changes: 2 additions & 0 deletions usr.bin/mklocale/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ PROG= mklocale
SRCS= yacc.y lex.l y.tab.h
CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/locale

NO_WMISSING_VARIABLE_DECLARATIONS=

.include <bsd.prog.mk>
1 change: 1 addition & 0 deletions usr.sbin/auditdistd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ OPENBSMDIR=${.CURDIR}/../../contrib/openbsm
CFLAGS+=-I${OPENBSMDIR} -I${OPENBSMDIR}/bin/auditdistd

NO_WFORMAT=
NO_WMISSING_VARIABLE_DECLARATIONS=

PROG= auditdistd
SRCS= auditdistd.c
Expand Down
2 changes: 2 additions & 0 deletions usr.sbin/bluetooth/bthidd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ DEBUG_FLAGS= -g
DPADD= ${LIBBLUETOOTH} ${LIBUSBHID}
LDADD= -lbluetooth -lusbhid

NO_WMISSING_VARIABLE_DECLARATIONS=

.include <bsd.prog.mk>
2 changes: 2 additions & 0 deletions usr.sbin/bsnmpd/modules/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ MANFILTER= sed -e 's%@MODPATH@%${LIBDIR}/%g' \
-e 's%@DEFPATH@%${DEFSDIR}/%g' \
-e 's%@MIBSPATH@%${BMIBSDIR}/%g'

NO_WMISSING_VARIABLE_DECLARATIONS=

.include "../Makefile.inc"
2 changes: 2 additions & 0 deletions usr.sbin/config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ kernconf.c: kernconf.tmpl

CFLAGS+= -I. -I${.CURDIR}

NO_WMISSING_VARIABLE_DECLARATIONS=

DPADD= ${LIBL} ${LIBSBUF}
LDADD= -ll -lsbuf

Expand Down
2 changes: 2 additions & 0 deletions usr.sbin/fifolog/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ SRCS+= getdate.y

CFLAGS+= -I${.CURDIR}

NO_WMISSING_VARIABLE_DECLARATIONS=

.include <bsd.lib.mk>
2 changes: 2 additions & 0 deletions usr.sbin/jail/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ SRCS= jail.c command.c config.c state.c jailp.h jaillex.l jailparse.y y.tab.h
DPADD= ${LIBJAIL} ${LIBKVM} ${LIBUTIL} ${LIBL}
LDADD= -ljail -lkvm -lutil -ll

NO_WMISSING_VARIABLE_DECLARATIONS=

YFLAGS+=-v
CFLAGS+=-I. -I${.CURDIR}

Expand Down

0 comments on commit 1201257

Please sign in to comment.