public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Macleod <amacleod@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4557] Ensure arguments to range-op handler are supported. Date: Thu, 8 Dec 2022 13:53:22 +0000 (GMT) [thread overview] Message-ID: <20221208135322.B9E9F3938D24@sourceware.org> (raw) https://gcc.gnu.org/g:0ef9991d8767932f51fa97753c16058d17b29b18 commit r13-4557-g0ef9991d8767932f51fa97753c16058d17b29b18 Author: Andrew MacLeod <amacleod@redhat.com> Date: Tue Dec 6 10:41:29 2022 -0500 Ensure arguments to range-op handler are supported. PR tree-optimization/107985 gcc/ * gimple-range-op.cc (gimple_range_op_handler::gimple_range_op_handler): Check if type of the operands is supported. * gimple-range.cc (gimple_ranger::prefill_stmt_dependencies): Do not assert if here is no range-op handler. gcc/testsuite/ * g++.dg/pr107985.C: New. Diff: --- gcc/gimple-range-op.cc | 6 ++++++ gcc/gimple-range.cc | 24 +++++++++++++----------- gcc/testsuite/g++.dg/pr107985.C | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 7764166d5fb..12068544bc5 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -148,6 +148,9 @@ gimple_range_op_handler::gimple_range_op_handler (gimple *s) case GIMPLE_COND: m_op1 = gimple_cond_lhs (m_stmt); m_op2 = gimple_cond_rhs (m_stmt); + // Check that operands are supported types. One check is enough. + if (!Value_Range::supports_type_p (TREE_TYPE (m_op1))) + m_valid = false; return; case GIMPLE_ASSIGN: m_op1 = gimple_range_base_of_assignment (m_stmt); @@ -164,6 +167,9 @@ gimple_range_op_handler::gimple_range_op_handler (gimple *s) } if (gimple_num_ops (m_stmt) >= 3) m_op2 = gimple_assign_rhs2 (m_stmt); + // Check that operands are supported types. One check is enough. + if ((m_op1 && !Value_Range::supports_type_p (TREE_TYPE (m_op1)))) + m_valid = false; return; default: gcc_unreachable (); diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index ecd6039e0fd..8c055826e17 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -422,18 +422,20 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa) else { gimple_range_op_handler handler (stmt); - gcc_checking_assert (handler); - tree op = handler.operand2 (); - if (op) + if (handler) { - Value_Range r (TREE_TYPE (op)); - prefill_name (r, op); - } - op = handler.operand1 (); - if (op) - { - Value_Range r (TREE_TYPE (op)); - prefill_name (r, op); + tree op = handler.operand2 (); + if (op) + { + Value_Range r (TREE_TYPE (op)); + prefill_name (r, op); + } + op = handler.operand1 (); + if (op) + { + Value_Range r (TREE_TYPE (op)); + prefill_name (r, op); + } } } } diff --git a/gcc/testsuite/g++.dg/pr107985.C b/gcc/testsuite/g++.dg/pr107985.C new file mode 100644 index 00000000000..8d244b54efb --- /dev/null +++ b/gcc/testsuite/g++.dg/pr107985.C @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-vrp -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre" } */ + +struct B { + int f; +}; + +struct D : public B { +}; + +void foo() { + D d; + d.f = 7; + + int B::* pfb = &B::f; + int D::* pfd = pfb; + int v = d.*pfd; +}
reply other threads:[~2022-12-08 13:53 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221208135322.B9E9F3938D24@sourceware.org \ --to=amacleod@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).