Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH 1/2] Update gcc warning checks to work with gcc-4.9
Date: Fri, 12 Sep 2014 15:48:03
Message-Id: 1410536863-17389-1-git-send-email-mgorny@gentoo.org
1 Use -W indicators whenever possible, or more flexible regular
2 expressions so that our checks correctly match output with
3 -fdiagnostics-color in gcc 4.9. Also, enable a few extra warnings that
4 are triggered by -W flags we already use and clean up some outdated
5 matches.
6
7 The check is confirmed to work correctly with gcc branches 4.7 up to
8 4.9.
9
10 Suggested-by: Ryan Hill <rhill@g.o>
11 Fixes: https://bugs.gentoo.org/show_bug.cgi?id=508364
12 ---
13
14 (both patches are based off install-qa-refactor branch)
15
16 bin/install-qa-check.d/90gcc-warnings | 82 +++++++++++++++++++++--------------
17 1 file changed, 49 insertions(+), 33 deletions(-)
18
19 diff --git a/bin/install-qa-check.d/90gcc-warnings b/bin/install-qa-check.d/90gcc-warnings
20 index ae39485..812bf41 100644
21 --- a/bin/install-qa-check.d/90gcc-warnings
22 +++ b/bin/install-qa-check.d/90gcc-warnings
23 @@ -13,44 +13,60 @@ gcc_warn_check() {
24 reset_debug=1
25 fi
26 local m msgs=(
27 - ": warning: dereferencing type-punned pointer will break strict-aliasing rules"
28 - ": warning: dereferencing pointer .* does break strict-aliasing rules"
29 - ": warning: implicit declaration of function"
30 - ": warning: incompatible implicit declaration of built-in function"
31 - ": warning: is used uninitialized in this function" # we'll ignore "may" and "might"
32 - ": warning: comparisons like X<=Y<=Z do not have their mathematical meaning"
33 - ": warning: null argument where non-null required"
34 - ": warning: array subscript is below array bounds"
35 - ": warning: array subscript is above array bounds"
36 - ": warning: attempt to free a non-heap object"
37 - ": warning: .* called with .*bigger.* than .* destination buffer"
38 - ": warning: call to .* will always overflow destination buffer"
39 - ": warning: assuming pointer wraparound does not occur when comparing"
40 - ": warning: hex escape sequence out of range"
41 - ": warning: [^ ]*-hand operand of comma .*has no effect"
42 - ": warning: converting to non-pointer type .* from NULL"
43 - ": warning: NULL used in arithmetic"
44 - ": warning: passing NULL to non-pointer argument"
45 - ": warning: the address of [^ ]* will always evaluate as"
46 - ": warning: the address of [^ ]* will never be NULL"
47 - ": warning: too few arguments for format"
48 - ": warning: reference to local variable .* returned"
49 - ": warning: returning reference to temporary"
50 - ": warning: function returns address of local variable"
51 - ": warning: .*\\[-Wsizeof-pointer-memaccess\\]"
52 - ": warning: .*\\[-Waggressive-loop-optimizations\\]"
53 + # only will, no might :)
54 + 'warning: .*will.*\[-Wstrict-aliasing\]'
55 + # implicit declaration of function ‘...’
56 + 'warning: .*\[-Wimplicit-function-declaration\]'
57 + # with -Wall, goes in pair with -Wimplicit-function-declaration
58 + # but without -Wall, we need to assert for it alone
59 + 'warning: .*incompatible implicit declaration of built-in function'
60 + # 'is used uninitialized in this function' and some more
61 + 'warning: .*\[-Wuninitialized\]'
62 + # comparisons like ‘X<=Y<=Z’ do not have their mathematical meaning
63 + 'warning: .*mathematical meaning*\[-Wparentheses\]'
64 + # null argument where non-null required
65 + 'warning: .*\[-Wnonnull\]'
66 + # array subscript is above/below/outside array bounds
67 + 'warning: .*\[-Warray-bounds\]'
68 + # attempt to free a non-heap object
69 + 'warning: .*\[-Wfree-nonheap-object\]'
70 + # those three do not have matching -W flags, it seems
71 + 'warning: .*will always overflow destination buffer'
72 + 'warning: .*assuming pointer wraparound does not occur'
73 + 'warning: .*escape sequence out of range'
74 + # left/right-hand operand of comma expression has no effect
75 + 'warning: .*comma.*\[-Wunused-value\]'
76 + # converting to non-pointer type ... from NULL and likes
77 + 'warning: .*\[-Wconversion-null\]'
78 + # NULL used in arithmetic
79 + 'warning: .*NULL.*\[-Wpointer-arith\]'
80 + # pointer to a function used in arithmetic and likes
81 + 'warning: .*function.*\[-Wpointer-arith\]'
82 + # the address of ... will never be NULL and likes
83 + # (uses of function refs & string constants in conditionals)
84 + 'warning: .*\[-Waddress\]'
85 + # format ... expects a matching ... argument
86 + # (iow, too few arguments for format in new wording :))
87 + 'warning: .*matching.*\[-Wformat=\]'
88 + # function returns address of local variable
89 + 'warning: .*\[-Wreturn-local-addr\]'
90 + # argument to sizeof ... is the same expression as the source
91 + 'warning: .*\[-Wsizeof-pointer-memaccess\]'
92 + # iteration invokes undefined behavior
93 + 'warning: .*\[-Waggressive-loop-optimizations\]'
94 +
95 # this may be valid code :/
96 - #": warning: multi-character character constant"
97 + #': warning: multi-character character constant'
98 # need to check these two ...
99 - #": warning: assuming signed overflow does not occur when"
100 - #": warning: comparison with string literal results in unspecified behav"
101 + #': warning: assuming signed overflow does not occur when'
102 + #': warning: comparison with string literal results in unspecified behav'
103 # yacc/lex likes to trigger this one
104 - #": warning: extra tokens at end of .* directive"
105 + #': warning: extra tokens at end of .* directive'
106 # only gcc itself triggers this ?
107 - #": warning: .*noreturn.* function does return"
108 + #': warning: .*noreturn.* function does return'
109 # these throw false positives when 0 is used instead of NULL
110 - #": warning: missing sentinel in function call"
111 - #": warning: not enough variable arguments to fit a sentinel"
112 + #': warning: missing sentinel in function call'
113 + #': warning: not enough variable arguments to fit a sentinel'
114 )
115 local abort="no"
116 local i=0
117 --
118 2.1.0

Replies