[clang] [PowerPC] Align bcdsetsign Sema validation with other BCD builtins (PR #178121)

Aditi Medhane via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 29 21:59:44 PST 2026


================
@@ -12,6 +12,14 @@
   int i = 1;                        \
   float f = 1.0f;
 
+vector unsigned char test_bcdsetsign(void) {
+  DECL_COMMON_VARS
+  vector unsigned char res_a = __builtin_ppc_bcdsetsign(scalar, '\1'); // expected-error {{argument 0 must be of type '__vector unsigned char' (vector of 16 'unsigned char' values}}
+  vector unsigned char res_b = __builtin_ppc_bcdsetsign(vec, 2); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+  vector unsigned char res_c = __builtin_ppc_bcdsetsign(vec, -1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
+  return __builtin_ppc_bcdsetsign(vec, '\1');
----------------
AditiRM wrote:

The builtin prototype takes an `unsigned char `as the second argument.
`'\1'` is used in the valid case to match the exact type.
`2` and `-1` are used intentionally to test the **constant range check (0–1)**; they are constant expressions implicitly convertible to unsigned char, which is sufficient to trigger the intended diagnostic.

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


More information about the cfe-commits mailing list