Skip to content

Commit ed7a0d3

Browse files
authored
Merge pull request #6531 from tautschnig/null-cleanup
Use null_pointer_exprt
2 parents 5cfbeb8 + 40b57ea commit ed7a0d3

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

src/ansi-c/c_typecast.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,7 @@ void c_typecastt::implicit_typecast_followed(
537537
src_type.id()==ID_natural ||
538538
src_type.id()==ID_integer))
539539
{
540-
expr=exprt(ID_constant, orig_dest_type);
541-
expr.set(ID_value, ID_NULL);
540+
expr = null_pointer_exprt{to_pointer_type(orig_dest_type)};
542541
return; // ok
543542
}
544543

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,14 +1382,14 @@ void c_typecheck_baset::typecheck_expr_rel(
13821382
if(type0.id()==ID_pointer &&
13831383
simplify_expr(op1, *this).is_zero())
13841384
{
1385-
op1=constant_exprt(ID_NULL, type0);
1385+
op1 = null_pointer_exprt{to_pointer_type(type0)};
13861386
return;
13871387
}
13881388

13891389
if(type1.id()==ID_pointer &&
13901390
simplify_expr(op0, *this).is_zero())
13911391
{
1392-
op0=constant_exprt(ID_NULL, type1);
1392+
op0 = null_pointer_exprt{to_pointer_type(type1)};
13931393
return;
13941394
}
13951395

src/cpp/parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6743,7 +6743,7 @@ bool Parser::rPrimaryExpr(exprt &exp)
67436743
case TOK_NULLPTR:
67446744
lex.get_token(tk);
67456745
// as an exception, we set the width of pointer
6746-
exp=constant_exprt(ID_NULL, pointer_type(typet(ID_nullptr)));
6746+
exp = null_pointer_exprt{pointer_type(typet(ID_nullptr))};
67476747
set_location(exp, tk);
67486748
#ifdef DEBUG
67496749
std::cout << std::string(__indent, ' ') << "Parser::rPrimaryExpr 6\n";

unit/interpreter/interpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ SCENARIO("interpreter evaluation null pointer expressions")
4646
unsignedbv_typet java_char(16);
4747
pointer_typet pointer_type(java_char, 64);
4848

49-
constant_exprt constant_expr(ID_NULL, pointer_type);
49+
null_pointer_exprt constant_expr{pointer_type};
5050

5151
mp_vectort mp_vector = interpreter_test.evaluate(constant_expr);
5252

0 commit comments

Comments
 (0)