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 comparing the
TREE_CODE of the type to VOID_TYPE instead of
directly comparing to void_type_node.

gcc/
        * omp-simd-clone.cc (simd_clone_adjust_return_type): Use TREE_CODE
and VOID_TYPE when checking for void return type in adjusted functions.
        (simd_clone_adjust): Likewise.

Signed-off-by: Kevin Stefanov <[email protected]>
---
Hi all,

In this patch, I fix an issue with the
way OpenMP checks whether the return type
of a function it has made a SIMD clone is
void, which was causing an ICE.

Bugzilla EasyHack link:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111856

Bootstrapped and regression tested on
x86_64-pc-linux-gnu with enable-languages=all.

I don't have write access so could somebody
commit this for me when it's ready to?

 gcc/omp-simd-clone.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc
index 7564846fac4..2f4cfcccb17 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 (TREE_CODE (orig_rettype) == VOID_TYPE)
     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 (TREE_CODE (orig_rettype) != VOID_TYPE)
     {
       poly_uint64 veclen;
       if (INTEGRAL_TYPE_P (orig_rettype) || POINTER_TYPE_P (orig_rettype))
-- 
2.54.0

Reply via email to