File tree Expand file tree Collapse file tree 10 files changed +28
-9
lines changed
approx-const-fp-array-variable-const-fp-with-null
approx-const-fp-array-variable-struct-const-fp-with-zero
no-match-array-literal-const-fp-null
no-match-const-fp-const-fp-null
no-match-const-fp-const-pointer-const-struct-const-fp-null
no-match-const-fp-dereference-const-pointer-null
no-match-const-struct-non-const-fp-null Expand file tree Collapse file tree 10 files changed +28
-9
lines changed Original file line number Diff line number Diff line change 5
5
^\s*IF fp == f2 THEN GOTO [0-9]$
6
6
^\s*IF fp == f3 THEN GOTO [0-9]$
7
7
^\s*IF fp == f4 THEN GOTO [0-9]$
8
+ replacing function pointer by 3 possible targets
8
9
^SIGNAL=0$
9
10
--
10
11
^warning: ignoring
Original file line number Diff line number Diff line change 1
- KNOWNBUG
1
+ CORE
2
2
main.c
3
3
--show-goto-functions --verbosity 10 --pointer-check
4
4
^Removing function pointers and virtual functions$
Original file line number Diff line number Diff line change 4
4
^Removing function pointers and virtual functions$
5
5
^\s*ASSERT FALSE // invalid function pointer$
6
6
^SIGNAL=0$
7
+ function func: replacing function pointer by 0 possible targets
7
8
--
8
9
^warning: ignoring
Original file line number Diff line number Diff line change 4
4
^Removing function pointers and virtual functions$
5
5
^\s*ASSERT FALSE // invalid function pointer$
6
6
^SIGNAL=0$
7
+ replacing function pointer by 0 possible targets
7
8
--
8
9
^warning: ignoring
Original file line number Diff line number Diff line change 3
3
--show-goto-functions --verbosity 10 --pointer-check
4
4
^Removing function pointers and virtual functions$
5
5
^\s*ASSERT FALSE // invalid function pointer$
6
+ replacing function pointer by 9 possible targets
6
7
^SIGNAL=0$
7
8
--
8
9
^warning: ignoring
Original file line number Diff line number Diff line change 3
3
--show-goto-functions --verbosity 10 --pointer-check
4
4
^Removing function pointers and virtual functions$
5
5
^\s*ASSERT FALSE // invalid function pointer$
6
+ replacing function pointer by 9 possible targets
6
7
^SIGNAL=0$
7
8
--
8
9
^warning: ignoring
Original file line number Diff line number Diff line change 3
3
--show-goto-functions --verbosity 10 --pointer-check
4
4
^Removing function pointers and virtual functions$
5
5
^\s*ASSERT FALSE // invalid function pointer$
6
+ function func: replacing function pointer by 0 possible targets
6
7
--
7
8
^warning: ignoring
Original file line number Diff line number Diff line change 4
4
^Removing function pointers and virtual functions$
5
5
^\s*ASSERT FALSE // invalid function pointer$
6
6
^SIGNAL=0$
7
+ replacing function pointer by 0 possible targets
7
8
--
8
9
^warning: ignoring
Original file line number Diff line number Diff line change @@ -164,6 +164,20 @@ bool remove_const_function_pointerst::try_resolve_function_call(
164
164
resolved=false ;
165
165
}
166
166
}
167
+ else if (simplified_expr.id ()==ID_constant)
168
+ {
169
+ if (simplified_expr.is_zero ())
170
+ {
171
+ // We have the null pointer - no need to throw everything away
172
+ // but we don't add any functions either
173
+ resolved=true ;
174
+ }
175
+ else
176
+ {
177
+ LOG (" Non-zero constant value found" , simplified_expr);
178
+ resolved=false ;
179
+ }
180
+ }
167
181
else
168
182
{
169
183
LOG (" Unrecognised expression" , simplified_expr);
@@ -555,10 +569,7 @@ bool remove_const_function_pointerst::try_resolve_index_of(
555
569
556
570
for (const exprt &resolved_array_entry : array_contents)
557
571
{
558
- if (!resolved_array_entry.is_zero ())
559
- {
560
- out_expressions.push_back (resolved_array_entry);
561
- }
572
+ out_expressions.push_back (resolved_array_entry);
562
573
}
563
574
}
564
575
}
Original file line number Diff line number Diff line change @@ -296,10 +296,11 @@ void remove_function_pointerst::remove_function_pointer(
296
296
297
297
found_functions=fpr (pointer, functions);
298
298
299
- // Either found_functions is true therefore the functions should not
300
- // be empty
301
- // Or found_functions is false therefore the functions should be empty
302
- assert (found_functions != functions.empty ());
299
+ // if found_functions is false, functions should be empty
300
+ // however, it is possible for found_functions to be true and functions
301
+ // to be empty (this happens if the pointer can only resolve to the null
302
+ // pointer)
303
+ assert (found_functions || functions.empty ());
303
304
304
305
if (functions.size ()==1 )
305
306
{
You can’t perform that action at this time.
0 commit comments