| 1 |
# This file is part of GNU cflow testsuite. -*- Autotest -*- |
| 2 |
# Copyright (C) 2006-2025 Sergey Poznyakoff |
| 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([Static symbols with forward decls and -i^s]) |
| 18 |
AT_KEYWORDS([static fdecl]) |
| 19 |
|
| 20 |
# Up to version 1.1 static symbols with forward declarations caused |
| 21 |
# segmentation faults when used with -i^s. |
| 22 |
# |
| 23 |
# Synopsis: Normally static functions are not added to callee lists |
| 24 |
# of their callers in -i^s mode (see add_reference() and call() in parser.c), |
| 25 |
# therefore cflow 1.1 assumed it was safe to free them in static_processor(). |
| 26 |
# However, there is an important exception: if the function storage type is |
| 27 |
# not known at the time of reference. Such functions are added to callee lists |
| 28 |
# and freeing them causes coredumps. |
| 29 |
# |
| 30 |
# To reproduce the case we need two source files: first with the actual test |
| 31 |
# program and the second, empty, one, whose purpose is to trigger additional |
| 32 |
# memory allocations after symbol deletion. |
| 33 |
# |
| 34 |
# Reported by: Laurent Fournie |
| 35 |
# References: <OFA772D453.E40E7252-ONC12571D8.0046430B-C12571D8.004B043A@rockwellcollins.com> |
| 36 |
|
| 37 |
AT_DATA([prog],[ |
| 38 |
static void foo(); |
| 39 |
|
| 40 |
int |
| 41 |
bar() |
| 42 |
{ |
| 43 |
foo(); |
| 44 |
} |
| 45 |
|
| 46 |
static void |
| 47 |
foo() |
| 48 |
{ |
| 49 |
int x = 1; |
| 50 |
} |
| 51 |
]) |
| 52 |
|
| 53 |
AT_DATA([2],[ |
| 54 |
]) |
| 55 |
|
| 56 |
CFLOW_OPT([-i^s],[ |
| 57 |
CFLOW_CHECK_PROG([prog 2], |
| 58 |
[bar() <int bar () at prog:5>: |
| 59 |
]) |
| 60 |
]) |
| 61 |
|
| 62 |
AT_CLEANUP |