Skip to content

Commit 1bca129

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2665 from tautschnig/gcc-conditional-stmt
Clean GCC conditional expressions in right-hand sides of declarations
2 parents da7966c + 96d345b commit 1bca129

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

regression/cbmc/gcc_conditional_expr1/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
#include <assert.h>
2+
13
int g, k;
24

5+
// See https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html
36
int main()
47
{
58
int r1, r2;
@@ -14,4 +17,10 @@ int main()
1417
assert(r2==1);
1518
assert(g==2);
1619
assert(k==0);
20+
21+
int in_decl = g++ ?: 0;
22+
assert(in_decl == 2);
23+
assert(g == 3);
24+
25+
return 0;
1726
}

src/goto-programs/goto_convert.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,8 @@ void goto_convertt::convert_assign(
758758
(rhs.get(ID_statement) == ID_assign ||
759759
rhs.get(ID_statement) == ID_postincrement ||
760760
rhs.get(ID_statement) == ID_preincrement ||
761-
rhs.get(ID_statement) == ID_statement_expression))
761+
rhs.get(ID_statement) == ID_statement_expression ||
762+
rhs.get(ID_statement) == ID_gcc_conditional_expression))
762763
{
763764
// handle above side effects
764765
clean_expr(rhs, dest, mode);

0 commit comments

Comments
 (0)