Use -W indicators whenever possible, or more flexible regular
expressions so that our checks correctly match output with
-fdiagnostics-color in gcc 4.9. Also, enable a few extra warnings that
are triggered by -W flags we already use and clean up some outdated
matches.

The check is confirmed to work correctly with gcc branches 4.7 up to
4.9.

Suggested-by: Ryan Hill <rh...@gentoo.org>
Fixes: https://bugs.gentoo.org/show_bug.cgi?id=508364
---

(both patches are based off install-qa-refactor branch)

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

diff --git a/bin/install-qa-check.d/90gcc-warnings 
b/bin/install-qa-check.d/90gcc-warnings
index ae39485..812bf41 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -13,44 +13,60 @@ 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, no might :)
+                       'warning: .*will.*\[-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\]'
+                       # 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
-- 
2.1.0


Reply via email to