Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 94e833d

Browse files
author
Daniel Kroening
authoredApr 19, 2017
Merge pull request #739 from NlightNFotis/bugfix/static_function
Bugfix/static function
2 parents d41332a + 62995f5 commit 94e833d

File tree

14 files changed

+54
-10
lines changed

14 files changed

+54
-10
lines changed
 

‎regression/ansi-c/static1/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
static int fun(int a)
2+
{
3+
return a+1;
4+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33
--function fun
44
^EXIT=0$
55
^SIGNAL=0$
6-
^VERIFICATION SUCCESSFUL$
76
--
87
^warning: ignoring

‎regression/ansi-c/static2/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
int foo(int a)
2+
{
3+
return a+1;
4+
}

‎regression/ansi-c/static2/main2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
static int foo(int a)
2+
{
3+
return a+1;
4+
}

‎regression/ansi-c/static2/test.desc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
main.c
3+
main2.c --function foo
4+
^main symbol `foo' is ambiguous$
5+
--
6+
^warning: ignoring

‎regression/ansi-c/static3/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
static int foo(int a)
2+
{
3+
return a+1;
4+
}

‎regression/ansi-c/static3/main2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
static int foo(int a)
2+
{
3+
return a+1;
4+
}

‎regression/ansi-c/static3/test.desc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
main.c
3+
main2.c --function foo
4+
^main symbol `foo' is ambiguous$
5+
--
6+
^warning: ignoring
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33

44
^EXIT=0$
55
^SIGNAL=0$
6-
^VERIFICATION SUCCESSFUL$
76
--
87
^warning: ignoring

‎regression/ansi-c/static_inline2/main.c

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎regression/cbmc/Static4/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
static int foo(int a)
2+
{
3+
return a+1;
4+
}

‎regression/cbmc/Static4/test.desc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
--show-symbol-table
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^Symbol......: foo

‎src/goto-programs/goto_inline.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ void goto_partial_inline(
213213
// called function
214214
const goto_functiont &goto_function=f_it->second;
215215

216-
if(!goto_function.body_available())
216+
// We can't take functions without bodies to find functions
217+
// inside them to be inlined.
218+
// We also don't allow for the _start function to have any of its
219+
// function calls to be inlined
220+
if(!goto_function.body_available() ||
221+
f_it->first==goto_functions.entry_point())
217222
continue;
218223

219224
const goto_programt &goto_program=goto_function.body;

‎src/linking/remove_internal_symbols.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening
1111
#include <util/find_symbols.h>
1212
#include <util/std_types.h>
1313
#include <util/cprover_prefix.h>
14+
#include <util/config.h>
1415

1516
#include "remove_internal_symbols.h"
1617

@@ -149,7 +150,8 @@ void remove_internal_symbols(
149150
else if(is_function)
150151
{
151152
// body? not local (i.e., "static")?
152-
if(has_body && !is_file_local)
153+
if(has_body &&
154+
(!is_file_local || (config.main==symbol.name.c_str())))
153155
get_symbols_rec(ns, symbol, exported);
154156
}
155157
else

0 commit comments

Comments
 (0)
Please sign in to comment.