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.
+2020-02-10 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/93405
+ * region-model.cc (region_model::get_lvalue_1): Implement
+ CONST_DECL.
+
2020-02-06 David Malcolm <dmalcolm@redhat.com>
* region-model.cc (region_model::maybe_cast_1): Attempt to provide
}
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);
+2020-02-10 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/93405
+ * gfortran.dg/analyzer/pr93405.f90: New test.
+
2020-02-10 David Malcolm <dmalcolm@redhat.com>
* gfortran.dg/analyzer/analyzer.exp: New subdirectory and .exp
--- /dev/null
+! { dg-do compile }
+real a(10), b(10), c(10)
+a = 0.
+b = 1.
+call sum(a, b, c, 10)
+print *, c(5)
+end
+subroutine sum(a, b, c, n)
+integer i, n
+real a(n), b(n), c(n)
+do i = 1, n
+ c(i) = a(i) + b(i)
+enddo
+end