public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Sebor <msebor@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7467] Call mark_dfs_back_edges before testing EDGE_DFS_BACK [PR104761]. Date: Thu, 3 Mar 2022 21:02:10 +0000 (GMT) [thread overview] Message-ID: <20220303210210.8B0C33858D39@sourceware.org> (raw) https://gcc.gnu.org/g:51149a05b8cc8e4fc5a77a65857894daa371de89 commit r12-7467-g51149a05b8cc8e4fc5a77a65857894daa371de89 Author: Martin Sebor <msebor@redhat.com> Date: Thu Mar 3 13:58:00 2022 -0700 Call mark_dfs_back_edges before testing EDGE_DFS_BACK [PR104761]. Resolves: PR middle-end/104761 - bogus -Wdangling-pointer with cleanup and infinite loop gcc/ChangeLog: PR middle-end/104761 * gimple-ssa-warn-access.cc (pass_waccess::execute): Call mark_dfs_back_edges. gcc/testsuite/ChangeLog: PR middle-end/104761 * g++.dg/warn/Wdangling-pointer-4.C: New test. * gcc.dg/Wdangling-pointer-4.c: New test. Diff: --- gcc/gimple-ssa-warn-access.cc | 5 ++++- gcc/testsuite/g++.dg/warn/Wdangling-pointer-4.C | 22 ++++++++++++++++++++++ gcc/testsuite/gcc.dg/Wdangling-pointer-4.c | 22 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc index b7cdad517b3..b519712d76e 100644 --- a/gcc/gimple-ssa-warn-access.cc +++ b/gcc/gimple-ssa-warn-access.cc @@ -47,7 +47,7 @@ #include "tree-object-size.h" #include "tree-ssa-strlen.h" #include "calls.h" -#include "cfgloop.h" +#include "cfganal.h" #include "intl.h" #include "gimple-range.h" #include "stringpool.h" @@ -4710,6 +4710,9 @@ pass_waccess::execute (function *fun) calculate_dominance_info (CDI_DOMINATORS); calculate_dominance_info (CDI_POST_DOMINATORS); + /* Set or clear EDGE_DFS_BACK bits on back edges. */ + mark_dfs_back_edges (fun); + /* Create a new ranger instance and associate it with FUN. */ m_ptr_qry.rvals = enable_ranger (fun); m_func = fun; diff --git a/gcc/testsuite/g++.dg/warn/Wdangling-pointer-4.C b/gcc/testsuite/g++.dg/warn/Wdangling-pointer-4.C new file mode 100644 index 00000000000..7177a545970 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wdangling-pointer-4.C @@ -0,0 +1,22 @@ +/* PR middle-end/104761 - bogus -Wdangling-pointer with cleanup and infinite loop + { dg-do compile } + { dg-options "-O -Wall -fno-exceptions" } */ + +struct S { int i; }; + +struct X { ~X (); }; + +void g (int); + +void test (int i) +{ + S s = { 0 }; + + X x; + + if (i) + { + g (s.i); // { dg-bogus "-Wdangling-pointer" } + for ( ; ; ); + } +} diff --git a/gcc/testsuite/gcc.dg/Wdangling-pointer-4.c b/gcc/testsuite/gcc.dg/Wdangling-pointer-4.c new file mode 100644 index 00000000000..36c8da5113a --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wdangling-pointer-4.c @@ -0,0 +1,22 @@ +/* PR middle-end/104761 - bogus -Wdangling-pointer with cleanup and infinite loop + { dg-do compile } + { dg-options "-O -Wall" } */ + +typedef struct { int i; } S; + +void f (S **); + +int g (int); + +void nowarn (int x) +{ + S s = { 0 }; + + __attribute__((__cleanup__ (f))) S *p = 0; + + if (x) + { + g (s.i); // { dg-bogus "-Wdangling-pointer" } + for ( ; ; ); + } +}
reply other threads:[~2022-03-03 21:02 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=20220303210210.8B0C33858D39@sourceware.org \ --to=msebor@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).