]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Fix d_signed_or_unsigned_type is invoked for vector types (PR110193)
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 28 Jun 2023 15:38:16 +0000 (17:38 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Wed, 28 Jun 2023 15:53:11 +0000 (17:53 +0200)
This function can be invoked on VECTOR_TYPE, but the implementation
assumes it works on integer types only.  To fix, added a check whether
the type passed is any `__vector(T)' or non-integral type, and return
early by calling `signed_or_unsigned_type_for()' instead.

Problem was found by instrumenting TYPE_PRECISION and ICEing when
applied on VECTOR_TYPEs.

PR d/110193

gcc/d/ChangeLog:

* types.cc (d_signed_or_unsigned_type): Handle being called with any
vector or non-integral type.

gcc/d/types.cc

index a4c05bfb75f01ada0073ebf7db3dbe5c3cb4cab2..bdf07f83d4b07aeed389ff224f1bf2a4de1c8c55 100644 (file)
@@ -49,8 +49,8 @@ along with GCC; see the file COPYING3.  If not see
 static tree
 d_signed_or_unsigned_type (int unsignedp, tree type)
 {
-  if (TYPE_UNSIGNED (type) == (unsigned) unsignedp)
-    return type;
+  if (VECTOR_TYPE_P (type) || !ANY_INTEGRAL_TYPE_P (type))
+    return signed_or_unsigned_type_for (unsignedp, type);
 
   if (TYPE_PRECISION (type) == TYPE_PRECISION (d_cent_type))
     return unsignedp ? d_ucent_type : d_cent_type;