https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/180528
The previous check was way too loose and let everything except unsigned integer types through. See e.g. https://godbolt.org/z/3qY8EbK56 >From 8ed68a58dc6fb88061abddfe5f4111befd69631b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Mon, 9 Feb 2026 15:20:59 +0100 Subject: [PATCH] [clang] Fix checkMathBuiltinElementType SignedIntOrFloatTy checks --- clang/lib/Sema/SemaChecking.cpp | 2 +- clang/test/Sema/builtins-elementwise-math.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index e82c82d881a8a..89171246d0bcb 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2200,7 +2200,7 @@ checkMathBuiltinElementType(Sema &S, SourceLocation Loc, QualType ArgTy, } break; case Sema::EltwiseBuiltinArgTyRestriction::SignedIntOrFloatTy: - if (EltTy->isUnsignedIntegerType()) { + if (!EltTy->isSignedIntegerType() && !EltTy->isRealFloatingType()) { return S.Diag(Loc, diag::err_builtin_invalid_arg_type) << 1 << /* scalar or vector */ 5 << /* signed int */ 2 << /* or fp */ 1 << ArgTy; diff --git a/clang/test/Sema/builtins-elementwise-math.c b/clang/test/Sema/builtins-elementwise-math.c index 37be0e4ebbd28..47f78d658c922 100644 --- a/clang/test/Sema/builtins-elementwise-math.c +++ b/clang/test/Sema/builtins-elementwise-math.c @@ -43,6 +43,9 @@ void test_builtin_elementwise_abs(int i, double d, float4 v, int3 iv, unsigned u uv = __builtin_elementwise_abs(uv); // expected-error@-1 {{1st argument must be a scalar or vector of signed integer or floating-point types (was 'unsigned4' (vector of 4 'unsigned int' values))}} + + i = __builtin_elementwise_abs(&i); + // expected-error@-1 {{1st argument must be a scalar or vector of signed integer or floating-point types (was 'int *')}} } void test_builtin_elementwise_add_sat(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
