@@ -1044,15 +1044,16 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr)
10441044 new_expr = size_of_opt.value ();
10451045 }
10461046
1047+ source_locationt location = expr.source_location ();
10471048 new_expr.swap (expr);
1048-
1049+ expr. add_source_location () = location;
10491050 expr.add (ID_C_c_sizeof_type)=type;
10501051
10511052 // The type may contain side-effects.
10521053 if (!clean_code.empty ())
10531054 {
10541055 side_effect_exprt side_effect_expr (
1055- ID_statement_expression, void_type (), expr. source_location () );
1056+ ID_statement_expression, void_type (), location );
10561057 auto decl_block=code_blockt::from_list (clean_code);
10571058 decl_block.set_statement (ID_decl_block);
10581059 side_effect_expr.copy_to_operands (decl_block);
@@ -1064,8 +1065,9 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr)
10641065 // It is not obvious whether the type or 'e' should be evaluated
10651066 // first.
10661067
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);
10691071 expr.swap (comma_expr);
10701072 }
10711073}
@@ -4656,6 +4658,8 @@ class is_compile_time_constantt
46564658
46574659void c_typecheck_baset::make_constant (exprt &expr)
46584660{
4661+ source_locationt location = expr.find_source_location ();
4662+
46594663 // Floating-point expressions may require a rounding mode.
46604664 // ISO 9899:1999 F.7.2 says that the default is "round to nearest".
46614665 // Some compilers have command-line options to override.
@@ -4664,10 +4668,11 @@ void c_typecheck_baset::make_constant(exprt &expr)
46644668 adjust_float_expressions (expr, rounding_mode);
46654669
46664670 simplify (expr, *this );
4671+ expr.add_source_location () = location;
46674672
46684673 if (!is_compile_time_constantt (*this )(expr))
46694674 {
4670- error ().source_location =expr. find_source_location () ;
4675+ error ().source_location = location ;
46714676 error () << " expected constant expression, but got '" << to_string (expr)
46724677 << " '" << eom;
46734678 throw 0 ;
@@ -4676,13 +4681,15 @@ void c_typecheck_baset::make_constant(exprt &expr)
46764681
46774682void c_typecheck_baset::make_constant_index (exprt &expr)
46784683{
4684+ source_locationt location = expr.find_source_location ();
46794685 make_constant (expr);
46804686 make_index_type (expr);
46814687 simplify (expr, *this );
4688+ expr.add_source_location () = location;
46824689
46834690 if (!is_compile_time_constantt (*this )(expr))
46844691 {
4685- error ().source_location =expr. find_source_location () ;
4692+ error ().source_location = location ;
46864693 error () << " conversion to integer constant failed" << eom;
46874694 throw 0 ;
46884695 }
0 commit comments