[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 6 16:09:28 PST 2025


================
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) {
                      _2, _3, _4));
 }
 
+static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) {
+  // Don't promote integer types
+  if (QualType Ty = E->getType(); S.getASTContext().isPromotableIntegerType(Ty))
+    return S.DefaultFunctionArrayLvalueConversion(E);
+  return S.UsualUnaryConversions(E);
----------------
efriedma-quic wrote:

The "usual unary conversions" is not a term used by any specification, so there isn't any real meaning attached to it.  I think I'd prefer not to use a boolean, though, because operation you want here is different in a pretty subtle way.

I missed that this also impacts bitfields.

Whether we support enums here probably doesn't really matter, as long as we're consistent.  Bitfields are unfortunately weird, due to the way promotion works; we might want to reject due to the potential ambiguity.

https://github.com/llvm/llvm-project/pull/119423


More information about the cfe-commits mailing list