aboutsummaryrefslogtreecommitdiff
path: root/tests/multi.at
blob: 151acf4fa02df1a05a8152455d9762a421ebd3dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# This file is part of GNU cflow testsuite. -*- Autotest -*-
# Copyright (C) 2006, 2007, 2010 Jerry St.Clair
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.

AT_SETUP([multiple source files])
AT_KEYWORDS([multi])

CFLOW_OPT([-ix_], [

dnl Source file #1
AT_DATA([multi1], [
#include "multi2.h"
#include "multi3.h"

static int stat = 1;

int main(int argc, char **argv)
{
  static int local_stat;
  local_stat = foo1(glob) + foo2(stat);
  return local_stat;
}
])

dnl Source file #2
AT_DATA([multi2], [
#include "multi2.h"
#include "multi3.h"

int glob = 2;
static int stat = 10;

static void _bar(int x)
{
  glob = foo2(x);
}

int foo1(int y)
{
  int local = 1;
  _bar(local);
  return stat;
}
])

dnl Source file #3
AT_DATA([multi3], [
#include "multi3.h"

static int stat = 100;

static void _bar(int x)
{
  stat += x;
}

int foo2(int y)
{
  static int local_stat = 1;
  _bar(local_stat + y + glob);
  return local_stat;
}
])

dnl Expected output
AT_DATA([expout], 
[main() <int main (int argc, char **argv) at multi1:7>:
    local_stat <int local_stat at multi1:9>
    foo1() <int foo1 (int y) at multi2:13>:
        _bar() <void _bar (int x) at multi2:8>:
            glob <int glob at multi2:5>
            foo2() <int foo2 (int y) at multi3:11>:
                _bar() <void _bar (int x) at multi3:6>:
                    stat <int stat at multi3:4>
                local_stat <int local_stat at multi3:13>
                glob <int glob at multi2:5>
        stat <int stat at multi2:6>
    glob <int glob at multi2:5>
    foo2() <int foo2 (int y) at multi3:11>:
        _bar() <void _bar (int x) at multi3:6>:
            stat <int stat at multi3:4>
        local_stat <int local_stat at multi3:13>
        glob <int glob at multi2:5>
    stat <int stat at multi1:5>
])

AT_CHECK([cflow ]TEST_CFLOW_OPTIONS[ multi1 multi2 multi3], [0], [expout])

])

AT_CLEANUP

Return to:

Send suggestions and report system problems to the System administrator.