@@ -1044,15 +1044,16 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr)
1044
1044
new_expr = size_of_opt.value ();
1045
1045
}
1046
1046
1047
+ source_locationt location = expr.source_location ();
1047
1048
new_expr.swap (expr);
1048
-
1049
+ expr. add_source_location () = location;
1049
1050
expr.add (ID_C_c_sizeof_type)=type;
1050
1051
1051
1052
// The type may contain side-effects.
1052
1053
if (!clean_code.empty ())
1053
1054
{
1054
1055
side_effect_exprt side_effect_expr (
1055
- ID_statement_expression, void_type (), expr. source_location () );
1056
+ ID_statement_expression, void_type (), location );
1056
1057
auto decl_block=code_blockt::from_list (clean_code);
1057
1058
decl_block.set_statement (ID_decl_block);
1058
1059
side_effect_expr.copy_to_operands (decl_block);
@@ -1064,8 +1065,9 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr)
1064
1065
// It is not obvious whether the type or 'e' should be evaluated
1065
1066
// first.
1066
1067
1067
- binary_exprt comma_expr{
1068
- std::move (side_effect_expr), ID_comma, expr, expr.type ()};
1068
+ exprt comma_expr =
1069
+ binary_exprt{std::move (side_effect_expr), ID_comma, expr, expr.type ()}
1070
+ .with_source_location (location);
1069
1071
expr.swap (comma_expr);
1070
1072
}
1071
1073
}
@@ -4656,6 +4658,8 @@ class is_compile_time_constantt
4656
4658
4657
4659
void c_typecheck_baset::make_constant (exprt &expr)
4658
4660
{
4661
+ source_locationt location = expr.find_source_location ();
4662
+
4659
4663
// Floating-point expressions may require a rounding mode.
4660
4664
// ISO 9899:1999 F.7.2 says that the default is "round to nearest".
4661
4665
// Some compilers have command-line options to override.
@@ -4664,10 +4668,11 @@ void c_typecheck_baset::make_constant(exprt &expr)
4664
4668
adjust_float_expressions (expr, rounding_mode);
4665
4669
4666
4670
simplify (expr, *this );
4671
+ expr.add_source_location () = location;
4667
4672
4668
4673
if (!is_compile_time_constantt (*this )(expr))
4669
4674
{
4670
- error ().source_location =expr. find_source_location () ;
4675
+ error ().source_location = location ;
4671
4676
error () << " expected constant expression, but got '" << to_string (expr)
4672
4677
<< " '" << eom;
4673
4678
throw 0 ;
@@ -4676,13 +4681,15 @@ void c_typecheck_baset::make_constant(exprt &expr)
4676
4681
4677
4682
void c_typecheck_baset::make_constant_index (exprt &expr)
4678
4683
{
4684
+ source_locationt location = expr.find_source_location ();
4679
4685
make_constant (expr);
4680
4686
make_index_type (expr);
4681
4687
simplify (expr, *this );
4688
+ expr.add_source_location () = location;
4682
4689
4683
4690
if (!is_compile_time_constantt (*this )(expr))
4684
4691
{
4685
- error ().source_location =expr. find_source_location () ;
4692
+ error ().source_location = location ;
4686
4693
error () << " conversion to integer constant failed" << eom;
4687
4694
throw 0 ;
4688
4695
}
0 commit comments