From ecdb93224c56189a129e97c556fe6b78e1b15a63 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 27 Aug 2020 18:20:24 -0400 Subject: analyzer: fix ICE on casting float to pointer [PR96764] gcc/analyzer/ChangeLog: PR analyzer/96764 * region-model-manager.cc (region_model_manager::maybe_fold_unaryop): Handle VIEW_CONVERT_EXPR. (region_model_manager::get_or_create_cast): Move logic for real->integer casting to... (get_code_for_cast): ...this new function, and add logic for real->non-integer casts. (region_model_manager::maybe_fold_sub_svalue): Handle VIEW_CONVERT_EXPR. * region-model.cc (region_model::add_any_constraints_from_gassign): Likewise. * svalue.cc (svalue::maybe_undo_cast): Likewise. (unaryop_svalue::dump_to_pp): Likewise. gcc/testsuite/ChangeLog: PR analyzer/96764 * gcc.dg/analyzer/pr96764.c: New test. --- gcc/analyzer/svalue.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'gcc/analyzer/svalue.cc') diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index a1c6241..fcab578 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -128,16 +128,19 @@ svalue::maybe_get_constant () const return NULL_TREE; } -/* If this svalue is a cast (i.e a unaryop NOP_EXPR), return the underlying - svalue. +/* If this svalue is a cast (i.e a unaryop NOP_EXPR or VIEW_CONVERT_EXPR), + return the underlying svalue. Otherwise return NULL. */ const svalue * svalue::maybe_undo_cast () const { if (const unaryop_svalue *unaryop_sval = dyn_cast_unaryop_svalue ()) - if (unaryop_sval->get_op () == NOP_EXPR) - return unaryop_sval->get_arg (); + { + enum tree_code op = unaryop_sval->get_op (); + if (op == NOP_EXPR || op == VIEW_CONVERT_EXPR) + return unaryop_sval->get_arg (); + } return NULL; } @@ -566,7 +569,7 @@ unaryop_svalue::dump_to_pp (pretty_printer *pp, bool simple) const { if (simple) { - if (m_op == NOP_EXPR) + if (m_op == VIEW_CONVERT_EXPR || m_op == NOP_EXPR) { pp_string (pp, "CAST("); dump_tree (pp, get_type ()); -- cgit v1.1