Skip to content

Commit 0655bec

Browse files
committed
Assignment instruction: require base-type match, not an exact match
In Java it is common to find an assignment with types that match, but use different levels of symbol indirection: for example, a struct initialiser might refer to the object being initialised using a symbol type on the LHS, but using the full struct type for the constant initialiser. In general this level-of- indirection mismatch is acceptable, including in C programs.
1 parent 8f57192 commit 0655bec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/util/std_code.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Author: Daniel Kroening, [email protected]
1717
#include "expr_cast.h"
1818
#include "invariant.h"
1919
#include "std_expr.h"
20+
#include "base_type.h"
2021
#include "validate.h"
2122
#include "validate_code.h"
2223

@@ -296,14 +297,14 @@ class code_assignt:public codet
296297

297298
static void validate(
298299
const codet &code,
299-
const namespacet &,
300+
const namespacet &ns,
300301
const validation_modet vm = validation_modet::INVARIANT)
301302
{
302303
check(code, vm);
303304

304305
DATA_CHECK(
305306
vm,
306-
code.op0().type() == code.op1().type(),
307+
base_type_eq(code.op0().type(), code.op1().type(), ns),
307308
"lhs and rhs of assignment must have same type");
308309
}
309310

0 commit comments

Comments
 (0)