Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions regression/cbmc-cpp/lvalue1/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <cassert>
enum asd
{
ASD,
ABC
};

int main()
{
asd a = ASD, b = ASD;

// casts to references are lvalues
asd &c = (asd &)((int &)a |= (int &)b);
assert(a == ASD);
c = ABC;
assert(a == ABC);

// in C++, comma expressions are lvalues
(a, b) = ASD;
}
10 changes: 10 additions & 0 deletions regression/cbmc-cpp/lvalue1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
main.cpp

^EXIT=0$
^SIGNAL=0$
VERIFICATION SUCCESSFUL
--
^warning: ignoring
^CONVERSION ERROR$
--
2 changes: 1 addition & 1 deletion regression/systemc/Masc1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
main.cpp

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/systemc/MascInst1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
main.cpp

^EXIT=0$
Expand Down
2 changes: 1 addition & 1 deletion regression/systemc/This1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
main.cpp

^EXIT=0$
Expand Down
5 changes: 2 additions & 3 deletions src/cpp/cpp_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,8 @@ void cpp_typecheckt::new_temporary(
exprt &temporary)
{
// create temporary object
exprt tmp_object_expr=exprt(ID_side_effect, type);
tmp_object_expr.set(ID_statement, ID_temporary_object);
tmp_object_expr.add_source_location()= source_location;
side_effect_exprt tmp_object_expr(ID_temporary_object, type, source_location);
tmp_object_expr.set(ID_mode, ID_cpp);

exprt new_object(ID_new_object);
new_object.add_source_location()=tmp_object_expr.source_location();
Expand Down
2 changes: 2 additions & 0 deletions src/cpp/cpp_typecheck_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ bool cpp_typecheckt::user_defined_conversion_sequence(
ID_temporary_object, type, expr.source_location());
tmp_object_expr.copy_to_operands(deref);
tmp_object_expr.set(ID_C_lvalue, true);
tmp_object_expr.set(ID_mode, ID_cpp);

new_expr.swap(tmp_object_expr);
return true;
Expand Down Expand Up @@ -1390,6 +1391,7 @@ bool cpp_typecheckt::reference_binding(
// create temporary object
side_effect_exprt tmp(
ID_temporary_object, type.subtype(), expr.source_location());
tmp.set(ID_mode, ID_cpp);
// tmp.set(ID_C_lvalue, true);
tmp.add_to_operands(std::move(new_expr));
new_expr.swap(tmp);
Expand Down
4 changes: 4 additions & 0 deletions src/goto-programs/goto_clean_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@ void goto_convertt::clean_expr_address_of(
// do again
clean_expr_address_of(expr, dest, mode);
}
else if(expr.id() == ID_side_effect)
{
remove_side_effect(to_side_effect_expr(expr), dest, mode, true);
}
else
Forall_operands(it, expr)
clean_expr_address_of(*it, dest, mode);
Expand Down