File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed
tests/examples/find-global-state Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 17
17
<http://www.gnu.org/licenses/>.
18
18
*/
19
19
20
+ #include <stdio.h>
21
+
20
22
static int a_global ;
21
23
22
24
struct {
@@ -39,3 +41,9 @@ int test2(int j)
39
41
i += j ;
40
42
return j * i ;
41
43
}
44
+
45
+ int test3 (int k )
46
+ {
47
+ /* We should *not* report about __FUNCTION__ here: */
48
+ printf ("%s:%i:%s\n" , __FILE__ , __LINE__ , __FUNCTION__ );
49
+ }
Original file line number Diff line number Diff line change 21
21
def on_pass_execution (p , fn ):
22
22
if p .name == '*free_lang_data' :
23
23
for var in gcc .get_variables ():
24
+ type_ = var .decl .type
25
+
26
+ # Don't bother warning about an array of const e.g.
27
+ # const char []
28
+ if isinstance (type_ , gcc .ArrayType ):
29
+ item_type = type_ .dereference
30
+ if hasattr (item_type , 'const' ):
31
+ if item_type .const :
32
+ continue
33
+
24
34
gcc .inform (var .decl .location ,
25
35
'global state "%s %s" defined here'
26
- % (var . decl . type , var .decl ))
36
+ % (type_ , var .decl ))
27
37
28
38
gcc .register_callback (gcc .PLUGIN_PASS_EXECUTION ,
29
39
on_pass_execution )
Original file line number Diff line number Diff line change 1
- tests/examples/find-global-state/input.c:38 :14: note: global state "int i" defined here
2
- tests/examples/find-global-state/input.c:24 :3: note: global state "struct
1
+ tests/examples/find-global-state/input.c:40 :14: note: global state "int i" defined here
2
+ tests/examples/find-global-state/input.c:26 :3: note: global state "struct
3
3
{
4
4
int i;
5
5
} bar" defined here
6
- tests/examples/find-global-state/input.c:20 :12: note: global state "int a_global" defined here
6
+ tests/examples/find-global-state/input.c:22 :12: note: global state "int a_global" defined here
You can’t perform that action at this time.
0 commit comments