gcc/analyzer/ChangeLog:
PR analyzer/96699
* region-model-manager.cc
(region_model_manager::get_or_create_cast): Use FIX_TRUNC_EXPR for
casting from REAL_TYPE to INTEGER_TYPE.
gcc/testsuite/ChangeLog:
PR analyzer/96699
* gcc.dg/analyzer/pr96699.c: New test.
const svalue *
region_model_manager::get_or_create_cast (tree type, const svalue *arg)
{
+ gcc_assert (type);
+ if (arg->get_type ())
+ if (TREE_CODE (type) == INTEGER_TYPE
+ && TREE_CODE (arg->get_type ()) == REAL_TYPE)
+ return get_or_create_unaryop (type, FIX_TRUNC_EXPR, arg);
return get_or_create_unaryop (type, NOP_EXPR, arg);
}
--- /dev/null
+struct qi {
+ union {
+ int hj;
+ float sl;
+ };
+};
+
+void
+i2 (struct qi *la)
+{
+ if (la->hj == 0)
+ la->sl = 0.0f;
+}