From 41a9e940c7014f117738a9a59b31833047a1083d Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 5 Feb 2020 16:48:53 -0500 Subject: analyzer: fix ICE with fortran constant arguments (PR 93405) PR analyzer/93405 reports an ICE with -fanalyzer when passing a constant "by reference" in gfortran. The issue is that the constant is passed as an ADDR_EXPR of a CONST_DECL, and region_model::get_lvalue_1 doesn't know how to handle CONST_DECL. This patch implements it for CONST_DECL by providing a placeholder region, holding the CONST_DECL's value, fixing the ICE. gcc/analyzer/ChangeLog: PR analyzer/93405 * region-model.cc (region_model::get_lvalue_1): Implement CONST_DECL. gcc/testsuite/ChangeLog: PR analyzer/93405 * gfortran.dg/analyzer/pr93405.f90: New test. --- gcc/analyzer/ChangeLog | 6 ++++++ gcc/analyzer/region-model.cc | 13 +++++++++++++ 2 files changed, 19 insertions(+) (limited to 'gcc/analyzer') diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index ba59131..e24976b 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,3 +1,9 @@ +2020-02-10 David Malcolm + + PR analyzer/93405 + * region-model.cc (region_model::get_lvalue_1): Implement + CONST_DECL. + 2020-02-06 David Malcolm * region-model.cc (region_model::maybe_cast_1): Attempt to provide diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 60363c7..86a5b42 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -4690,6 +4690,19 @@ region_model::get_lvalue_1 (path_var pv, region_model_context *ctxt) } break; + case CONST_DECL: + { + tree cst_type = TREE_TYPE (expr); + region_id cst_rid = add_region_for_type (m_root_rid, cst_type); + if (tree value = DECL_INITIAL (expr)) + { + svalue_id sid = get_rvalue (value, ctxt); + get_region (cst_rid)->set_value (*this, cst_rid, sid, ctxt); + } + return cst_rid; + } + break; + case STRING_CST: { tree cst_type = TREE_TYPE (expr); -- cgit v1.1