[clang] [clang] Report Diagnostic when builtin vector has negative size (PR #166055)
Amr Hesham via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 3 09:18:32 PST 2025
================
@@ -786,3 +786,8 @@ const long long e = *0; // expected-error {{indirection requires pointer operand
double f = a - e; // expected-error {{cannot initialize a variable of type 'double' with an rvalue of type '__attribute__((__vector_size__(1 * sizeof(double)))) double' (vector of 1 'double' value)}}
int h = c - e; // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type '__attribute__((__vector_size__(1 * sizeof(long)))) long' (vector of 1 'long' value)}}
}
+
+typedef int v_neg_size __attribute__((vector_size(-8))); // expected-error{{vector must have non-negative size}}
+typedef int v_neg_size_2 __attribute__((vector_size(-1 * 8))); // expected-error{{vector must have non-negative size}}
+typedef int v_ext_neg_size __attribute__((ext_vector_type(-8))); // expected-error{{vector must have non-negative size}}
+typedef int v_ext_neg_size2 __attribute__((ext_vector_type(-1 * 8))); // expected-error{{vector must have non-negative size}}
----------------
AmrDeveloper wrote:
Yes, it works. I just need to write this test in another file that allows C++11 extension to be able to use `using`
https://github.com/llvm/llvm-project/pull/166055
More information about the cfe-commits
mailing list