[gcc r17-3262] testsuite: Add a returns_twice testcase for PR126815 [PR126815]

Andrea Pinski via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:ea9ca5b61117e57899e848def9124ea9f40aca49

commit r17-3262-gea9ca5b61117e57899e848def9124ea9f40aca49
Author: Andrea Pinski <[email protected]>
Date:   Thu Aug 13 09:53:50 2026 -0700

    testsuite: Add a returns_twice testcase for PR126815 [PR126815]
    
    This adds a returns_twice testcase that shows the ICE (already fixed)
    and show that adding a stmt before the call does not work either.
    
    Pushed as obvious after a quick test on x86_64-linux-gnu to make sure it passes.
    
            PR tree-optimization/126815
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/torture/returns-twice-1.c: New test.
    
    Signed-off-by: Andrea Pinski <[email protected]>

Diff:
---
 gcc/testsuite/gcc.dg/torture/returns-twice-1.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/returns-twice-1.c b/gcc/testsuite/gcc.dg/torture/returns-twice-1.c
new file mode 100644
index 000000000000..fbd9faa0bce6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/returns-twice-1.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* PR tree-optimization/126815 */
+int f (int) __attribute__((returns_twice));
+void sink1 (int) __attribute__((leaf));
+void sink (int);
+
+void h (int a, int b, int c)
+{
+  int t;
+  if (c){
+    sink (1);
+    t = f (a);
+  }
+  else
+    t = b;
+  if (t == 42)
+    __builtin_unreachable ();
+  sink1 (a);
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.