commit:     5346802bc7ca09955020d265b4a15e8ecf67a28f
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 12 09:26:26 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Sep 26 01:22:13 2014 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5346802b

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 <rhill <AT> gentoo.org>.

---
 bin/install-qa-check.d/90gcc-warnings | 85 +++++++++++++++++++++--------------
 1 file changed, 52 insertions(+), 33 deletions(-)

diff --git a/bin/install-qa-check.d/90gcc-warnings 
b/bin/install-qa-check.d/90gcc-warnings
index ae39485..48c11e4 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -13,44 +13,63 @@ 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"
+                       #': warning: multi-character character constant'
                        # need to check these two ...
-                       #": warning: assuming signed overflow does not occur 
when"
-                       #": warning: comparison with string literal results in 
unspecified behav"
+                       #': warning: assuming signed overflow does not occur 
when'
+                       #': warning: comparison with string literal results in 
unspecified behav'
                        # yacc/lex likes to trigger this one
-                       #": warning: extra tokens at end of .* directive"
+                       #': warning: extra tokens at end of .* directive'
                        # only gcc itself triggers this ?
-                       #": warning: .*noreturn.* function does return"
+                       #': warning: .*noreturn.* function does return'
                        # these throw false positives when 0 is used instead of 
NULL
-                       #": warning: missing sentinel in function call"
-                       #": warning: not enough variable arguments to fit a 
sentinel"
+                       #': warning: missing sentinel in function call'
+                       #': warning: not enough variable arguments to fit a 
sentinel'
                )
                local abort="no"
                local i=0

Reply via email to