public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] analyzer: fix ICE on 'bind' that returns a struct [PR107788]
@ 2022-11-22  0:15 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2022-11-22  0:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r13-4221-g4e4e45a4fd3411.

gcc/analyzer/ChangeLog:
	PR analyzer/107788
	* region-model.cc (region_model::update_for_int_cst_return):
	Require that the return type be an integer type.
	(region_model::update_for_nonzero_return): Likewise.

gcc/testsuite/ChangeLog:
	PR analyzer/107788
	* g++.dg/analyzer/fd-bind-pr107783.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
 gcc/analyzer/region-model.cc                     |  4 ++++
 gcc/testsuite/g++.dg/analyzer/fd-bind-pr107783.C | 11 +++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/analyzer/fd-bind-pr107783.C

diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 1d5b09a6805..e71fd41f62d 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -1930,6 +1930,8 @@ region_model::update_for_int_cst_return (const call_details &cd,
 {
   if (!cd.get_lhs_type ())
     return;
+  if (TREE_CODE (cd.get_lhs_type ()) != INTEGER_TYPE)
+    return;
   const svalue *result
     = m_mgr->get_or_create_int_cst (cd.get_lhs_type (), retval);
   if (unmergeable)
@@ -1955,6 +1957,8 @@ region_model::update_for_nonzero_return (const call_details &cd)
 {
   if (!cd.get_lhs_type ())
     return;
+  if (TREE_CODE (cd.get_lhs_type ()) != INTEGER_TYPE)
+    return;
   const svalue *zero
     = m_mgr->get_or_create_int_cst (cd.get_lhs_type (), 0);
   const svalue *result
diff --git a/gcc/testsuite/g++.dg/analyzer/fd-bind-pr107783.C b/gcc/testsuite/g++.dg/analyzer/fd-bind-pr107783.C
new file mode 100644
index 00000000000..eb5e23c82cf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/analyzer/fd-bind-pr107783.C
@@ -0,0 +1,11 @@
+// { dg-do compile { target c++11 } }
+
+struct minus {
+} _1;
+int _2;
+struct _Bind {
+  _Bind(_Bind &);
+};
+template <typename _Func, typename _BoundArgs>
+_Bind bind(_Func, _BoundArgs &&...);
+void test01() { bind(minus(), _2, _1); }
-- 
2.26.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-22  0:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22  0:15 [committed] analyzer: fix ICE on 'bind' that returns a struct [PR107788] David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).