To my surprise we accept generic vectors with enumeral element
types (unlike e.g. _Complex) and we don't actually try to
perform "integral" promotions for those either (which for scalars
promotes ENUMERAL_TYPE operands to their underlying type or
promoted underlying type). I'm afraid it is inappropriate
to change the promotions at this point in stage4, that would
be a significant user visible change (though sure for a feature
that hopefully nobody actually uses). Anyway, in GCC 16
development some assertions that RDIV_EXPR is only used for floating
(scalar/vector/complex) operands were added and those now trigger
on trying to divide vectors where both operands are enum vectors.
THis is due to the FEs using RDIV_EXPR instead of TRUNC_DIV_EXPR
when the operands (after promotions) don't have INTEGER_TYPE (or for C
BITINT_TYPE) operands.
This patch just adds vector enum to that.
2026-01-16 Jakub Jelinek <jakub@redhat.com>
Peter Damianov <peter0x44@disroot.org>
PR c/123437
* c-typeck.cc (build_binary_op): Don't use RDIV_EXPR
resultcode if both types are integral, _BitInt or
newly VECTOR_TYPE of ENUMERAL_TYPE.
* typeck.cc (cp_build_binary_op): Don't use RDIV_EXPR
resultcode if both types are integral, _BitInt or
newly VECTOR_TYPE of ENUMERAL_TYPE.
* c-c++-common/pr123437.c: New test.
if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
- if (!(((tcode0 == INTEGER_TYPE || tcode0 == BITINT_TYPE)
- && (tcode1 == INTEGER_TYPE || tcode1 == BITINT_TYPE))
+ if (!(((tcode0 == INTEGER_TYPE || tcode0 == BITINT_TYPE
+ || (tcode0 == ENUMERAL_TYPE && code0 == VECTOR_TYPE))
+ && (tcode1 == INTEGER_TYPE || tcode1 == BITINT_TYPE
+ || (tcode1 == ENUMERAL_TYPE && code1 == VECTOR_TYPE)))
|| (tcode0 == FIXED_POINT_TYPE && tcode1 == FIXED_POINT_TYPE)))
resultcode = RDIV_EXPR;
else
if (tcode1 == COMPLEX_TYPE || tcode1 == VECTOR_TYPE)
tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
- if (!(tcode0 == INTEGER_TYPE && tcode1 == INTEGER_TYPE))
+ if (!((tcode0 == INTEGER_TYPE
+ || (tcode0 == ENUMERAL_TYPE && code0 == VECTOR_TYPE))
+ && (tcode1 == INTEGER_TYPE
+ || (tcode1 == ENUMERAL_TYPE && code1 == VECTOR_TYPE))))
resultcode = RDIV_EXPR;
else
{
--- /dev/null
+/* PR c/123437 */
+/* { dg-do compile } */
+
+enum E { F };
+typedef enum E V __attribute__ ((vector_size (16)));
+V x, y, z;
+
+void
+foo ()
+{
+ z = x / y;
+}