[gcc r17-3156] OpenMP: Use VOID_TYPE_P to check for void return type in SIMD function clones.

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

commit r17-3156-ge212f5ef86f1a87c4471f8076a2cc6843ad10a20
Author: Kevin Stefanov <[email protected]>
Date:   Sat Aug 8 13:41:14 2026 +0300

    OpenMP: Use VOID_TYPE_P to check for void return type in SIMD function clones.
    
    This change fixes an issue where functions
    decorated with:
    pragma omp declare simd
    that return void via a typedef would crash
    GCC with an ICE while compiling a program
    containing such a function, by using
    VOID_TYPE_P instead of directly comparing
    to void_type_node. New testcase added.
    
            PR middle-end/111856
    
    gcc/ChangeLog:
    
            * omp-simd-clone.cc (simd_clone_adjust_return_type): Use VOID_TYPE_P
            when checking for void return type in adjusted functions.
            (simd_clone_adjust): Likewise.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/gomp/pr111856.c: New test.
    
    Signed-off-by: Kevin Stefanov <[email protected]>

Diff:
---
 gcc/omp-simd-clone.cc                |  4 ++--
 gcc/testsuite/gcc.dg/gomp/pr111856.c | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc
index 7564846fac4c..4f189f243a0d 100644
--- a/gcc/omp-simd-clone.cc
+++ b/gcc/omp-simd-clone.cc
@@ -715,7 +715,7 @@ simd_clone_adjust_return_type (struct cgraph_node *node)
   tree t;
 
   /* Adjust the function return type.  */
-  if (orig_rettype == void_type_node)
+  if (VOID_TYPE_P (orig_rettype))
     return;
   t = TREE_TYPE (TREE_TYPE (fndecl));
   if (INTEGRAL_TYPE_P (t) || POINTER_TYPE_P (t))
@@ -1370,7 +1370,7 @@ simd_clone_adjust (struct cgraph_node *node)
   simd_clone_adjust_argument_types (node);
   targetm.simd_clone.adjust (node);
   tree retval = NULL_TREE;
-  if (orig_rettype != void_type_node)
+  if (!VOID_TYPE_P (orig_rettype))
     {
       poly_uint64 veclen;
       if (INTEGRAL_TYPE_P (orig_rettype) || POINTER_TYPE_P (orig_rettype))
diff --git a/gcc/testsuite/gcc.dg/gomp/pr111856.c b/gcc/testsuite/gcc.dg/gomp/pr111856.c
new file mode 100644
index 000000000000..ef162f585319
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/pr111856.c
@@ -0,0 +1,11 @@
+/* PR middle-end/111856 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp-simd -O2" } */
+
+typedef void T;
+int array[1000];
+#pragma omp declare simd notinbranch simdlen(4)
+T foo (int i)
+{
+  array[i] = 555;
+}
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.