From 5818a6aac97b2c6d58a546e25d41277417054835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 12 Sep 2014 11:26:26 +0200 Subject: [PATCH] Update gcc warning checks to work with colored output Use -W indicators whenever possible, or more flexible regular expressions so that our checks correctly match output with -fdiagnostics-color. Also, enable a few extra warnings with some of the currently used -W flags. Based on the patch from Ryan Hill . --- bin/install-qa-check.d/90gcc-warnings | 71 ++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/bin/install-qa-check.d/90gcc-warnings b/bin/install-qa-check.d/90gcc-warnings index ae39485..1d7a8b7 100644 --- a/bin/install-qa-check.d/90gcc-warnings +++ b/bin/install-qa-check.d/90gcc-warnings @@ -13,32 +13,51 @@ gcc_warn_check() { reset_debug=1 fi local m msgs=( - ": warning: dereferencing type-punned pointer will break strict-aliasing rules" - ": warning: dereferencing pointer .* does break strict-aliasing rules" - ": warning: implicit declaration of function" - ": warning: incompatible implicit declaration of built-in function" - ": warning: is used uninitialized in this function" # we'll ignore "may" and "might" - ": warning: comparisons like X<=Y<=Z do not have their mathematical meaning" - ": warning: null argument where non-null required" - ": warning: array subscript is below array bounds" - ": warning: array subscript is above array bounds" - ": warning: attempt to free a non-heap object" - ": warning: .* called with .*bigger.* than .* destination buffer" - ": warning: call to .* will always overflow destination buffer" - ": warning: assuming pointer wraparound does not occur when comparing" - ": warning: hex escape sequence out of range" - ": warning: [^ ]*-hand operand of comma .*has no effect" - ": warning: converting to non-pointer type .* from NULL" - ": warning: NULL used in arithmetic" - ": warning: passing NULL to non-pointer argument" - ": warning: the address of [^ ]* will always evaluate as" - ": warning: the address of [^ ]* will never be NULL" - ": warning: too few arguments for format" - ": warning: reference to local variable .* returned" - ": warning: returning reference to temporary" - ": warning: function returns address of local variable" - ": warning: .*\\[-Wsizeof-pointer-memaccess\\]" - ": warning: .*\\[-Waggressive-loop-optimizations\\]" + # only will and does, no might :) + "warning: .*will.*\\[-Wstrict-aliasing\\]" + "warning: .*does.*\\[-Wstrict-aliasing\\]" + # implicit declaration of function ā€˜...ā€™ + "warning: .*\\[-Wimplicit-function-declaration\\]" + # with -Wall, goes in pair with -Wimplicit-function-declaration + # but without -Wall, we need to assert for it alone + "warning: .*incompatible implicit declaration of built-in function" + # 'is used uninitialized in this function' and some more + "warning: .*\\[-Wuninitialized\\]" + # comparisons like ā€˜X<=Y<=Zā€™ do not have their mathematical meaning + "warning: .*mathematical meaning*\\[-Wparentheses\\]" + # null argument where non-null required + "warning: .*\\[-Wnonnull\\]" + # array subscript is above/below/outside array bounds + "warning: .*\\[-Warray-bounds\\]" + # attempt to free a non-heap object + "warning: .*\\[-Wfree-nonheap-object\\]" + # those three do not have matching -W flags, it seems + "warning: .*will always overflow destination buffer" + "warning: .*assuming pointer wraparound does not occur" + "warning: .*escape sequence out of range" + # left/right-hand operand of comma expression has no effect + "warning: .*comma.*\\[-Wunused-value\\]" + # converting to non-pointer type ... from NULL and likes + "warning: .*\\[-Wconversion-null\\]" + # NULL used in arithmetic + "warning: .*NULL.*\\[-Wpointer-arith\\]" + # pointer to a function used in arithmetic and likes + "warning: .*function.*\\[-Wpointer-arith\\]" + # the address of ... will never be NULL and likes + # (uses of function refs & string constants in conditionals) + "warning: .*\\[-Waddress\\]" + # outdated? + "warning: .*too few arguments for format" + # format ... expects a matching ... argument + # (iow, too few arguments for format in new wording :)) + "warning: .*matching.*\\[-Wformat=\\]" + # function returns address of local variable + "warning: .*\\[-Wreturn-local-addr\\]" + # argument to sizeof ... is the same expression as the source + "warning: .*\\[-Wsizeof-pointer-memaccess\\]" + # iteration invokes undefined behavior + "warning: .*\\[-Waggressive-loop-optimizations\\]" + # this may be valid code :/ #": warning: multi-character character constant" # need to check these two ... -- 2.1.0