When compiling with -fopenmp-simd, there is an ICE if a function has a
return type of a typedef of void.  (e.g., "typedef void T; T foo()").

Corrected by changing:

if (orig_rettype == void_type_node)

to :

if (VOID_TYPE_P (orig_rettype))

gcc/ChangeLog:

        PR middle-end/111856
        * omp-simd-clone.cc (simd_clone_adjust_return_type): Use
        VOID_TYPE_P instead of comparison with void_type_node.
        (simd_clone_adjust): Likewise.

gcc/testsuite/ChangeLog:

        PR middle-end/111856
        * c-c++-common/gomp/pr111856.c: New test.
---
 gcc/omp-simd-clone.cc                      |  4 ++--
 gcc/testsuite/c-c++-common/gomp/pr111856.c | 12 ++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/gomp/pr111856.c

diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc
index 630864d948f..55f92242a09 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/c-c++-common/gomp/pr111856.c 
b/gcc/testsuite/c-c++-common/gomp/pr111856.c
new file mode 100644
index 00000000000..bd723519b7c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr111856.c
@@ -0,0 +1,12 @@
+/* PR middle-end/111856 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp-simd" } */
+
+typedef void T;
+
+int array[1000];
+#pragma omp declare simd notinbranch simdlen(4)
+T foo (int i)
+{
+  array[i] = 555;
+}
-- 
2.52.0

Reply via email to