File tree Expand file tree Collapse file tree 4 files changed +48
-0
lines changed
regression/cbmc/pragma_cprover2 Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ int foo (int x )
2+ {
3+ return x ;
4+ }
5+
6+ int main ()
7+ {
8+ int n ;
9+
10+ #pragma CPROVER check push
11+ #pragma CPROVER check disable "signed-overflow"
12+ // do not generate assertions for the following statements
13+ int x = n + n ;
14+ ++ n ;
15+ n ++ ;
16+ n += 1 ;
17+ foo (x + n );
18+ // pop all annotations
19+ #pragma CPROVER check pop
20+ // but do generate assertions for these
21+ x = n + n ;
22+ foo (x + n );
23+ return x ;
24+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --signed-overflow-check
4+ ^\[main.overflow\.1\] line 21 arithmetic overflow on signed \+ in n \+ n: FAILURE$
5+ ^\[main.overflow\.2\] line 22 arithmetic overflow on signed \+ in x \+ n: FAILURE$
6+ ^\*\* 2 of 2 failed
7+ ^VERIFICATION FAILED$
8+ ^EXIT=10$
9+ ^SIGNAL=0$
10+ --
11+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -243,7 +243,16 @@ void c_typecheck_baset::typecheck_decl(codet &code)
243243 }
244244
245245 ansi_c_declarationt declaration;
246+ irep_idt comment = code.source_location ().get_comment ();
246247 declaration.swap (code.op0 ());
248+ if (!comment.empty ())
249+ {
250+ for (auto &d : declaration.declarators ())
251+ {
252+ if (d.source_location ().get_comment ().empty ())
253+ d.add_source_location ().set_comment (comment);
254+ }
255+ }
247256
248257 if (declaration.get_is_static_assert ())
249258 {
Original file line number Diff line number Diff line change @@ -2019,6 +2019,10 @@ void c_typecheck_baset::typecheck_side_effect_function_call(
20192019 throw 0 ;
20202020 }
20212021
2022+ irep_idt comment = expr.source_location ().get_comment ();
2023+ if (!comment.empty () && f_op.source_location ().get_comment ().empty ())
2024+ f_op.add_source_location ().set_comment (comment);
2025+
20222026 const code_typet &code_type=to_code_type (f_op.type ());
20232027
20242028 expr.type ()=code_type.return_type ();
You can’t perform that action at this time.
0 commit comments