Debian Codegraph @

tests/hiding.at

raw
1 # This file is part of GNU cflow testsuite. -*- Autotest -*-
2 # Copyright (C) 2006, 2007, 2010 Jerry St.Clair
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 AT_SETUP([hiding of global and file static identifiers])
18 AT_KEYWORDS([hiding])
19
20 CFLOW_OPT([-ix_], [
21
22 CFLOW_CHECK([
23 static int s = 1;
24 int g = -100;
25
26 static
27 int foo()
28 {
29 static int s = 10; /* hides file static variable */
30 return s;
31 }
32
33 static
34 int bar()
35 {
36 static int foo = 100; /* hides file static function */
37 return foo + g;
38 }
39
40 int baz()
41 {
42 int g = 100; /* hides global variable */
43 return s + g;
44 }
45
46 int main()
47 {
48 return (g + s + foo() + bar() + baz());
49 }
50 ],
51 [main() <int main () at prog:25>:
52 g <int g at prog:3>
53 s <int s at prog:2>
54 foo() <int foo () at prog:6>:
55 s <int s at prog:8>
56 bar() <int bar () at prog:13>:
57 foo <int foo at prog:15>
58 g <int g at prog:3>
59 baz() <int baz () at prog:19>:
60 s <int s at prog:2>
61 ])
62 ])
63
64 AT_CLEANUP
65