#!/bin/bash
# clang -Wall plus other important warnings not included in -Wall

for arg in "$@"
do
	case $arg in
	-O*) Wuninitialized=-Wuninitialized;;  # only makes sense with `-O'
	esac
done

CLANG="clang${COMPILER_VERSION:+-$COMPILER_VERSION}"

#PEDANTIC="-std=gnu99"
#PEDANTIC="-pedantic -std=gnu99"
#PEDANTIC="-pedantic -std=gnu99 -Wno-variadic-macros"
#CONVERSION="-Wconversion"

EXTRA="\
 -Wextra \
 -Wsign-compare \
 -Wcast-align
 -Werror-implicit-function-declaration \
 -Wpointer-arith \
 -Wwrite-strings \
 -Wswitch \
 -Wmissing-format-attribute \
 -Winit-self \
 -Wold-style-definition \
 -Wno-missing-field-initializers \
 -Wunused-parameter \
 -Wno-long-long"

exec $CLANG $PEDANTIC $CONVERSION \
	-Wall $Wuninitialized \
	-Wno-switch \
	-Wdisabled-optimization \
	-Wwrite-strings \
	-Wpointer-arith \
	-Wbad-function-cast \
	-Wmissing-prototypes \
	-Wmissing-declarations \
	-Wstrict-prototypes \
	-Wnested-externs \
	-Wcomment \
	-Winline \
	-Wcast-qual \
	-Wredundant-decls $EXTRA \
	"$@"
