[clang] e1a9c04 - [test] Fixup builtin-assume-aligned.c
Arthur Eubanks via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 8 13:07:47 PDT 2021
Author: Arthur Eubanks
Date: 2021-10-08T13:07:28-07:00
New Revision: e1a9c0443533723300f76db10dcb221733420882
URL: https://github.com/llvm/llvm-project/commit/e1a9c0443533723300f76db10dcb221733420882
DIFF: https://github.com/llvm/llvm-project/commit/e1a9c0443533723300f76db10dcb221733420882.diff
LOG: [test] Fixup builtin-assume-aligned.c
__builtin_assume_aligned's second parameter is size_t, which may be 32 bits.
We can't pass 2^32 when that happens. Update tests accordingly.
Example broken bot due to D111250:
https://lab.llvm.org/buildbot/#/builders/171/builds/4531
Added:
Modified:
clang/test/Sema/builtin-assume-aligned.c
Removed:
################################################################################
diff --git a/clang/test/Sema/builtin-assume-aligned.c b/clang/test/Sema/builtin-assume-aligned.c
index 8a2e3bdc7881..cbe9e3a8caad 100644
--- a/clang/test/Sema/builtin-assume-aligned.c
+++ b/clang/test/Sema/builtin-assume-aligned.c
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DSIZE_T_64 -fsyntax-only -triple x86_64-linux -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple i386-freebsd -verify %s
+
+// __builtin_assume_aligned's second parameter is size_t, which may be 32 bits,
+// so test
diff erently when size_t is 32 bits and when it is 64 bits.
int test1(int *a) {
a = __builtin_assume_aligned(a, 32, 0ull);
@@ -17,9 +21,6 @@ int test3(int *a) {
int test4(int *a) {
a = __builtin_assume_aligned(a, -32); // expected-error {{requested alignment is not a power of 2}}
- // FIXME: The line below produces {{requested alignment is not a power of 2}}
- // on i386-freebsd, but not on x86_64-linux (for example).
- // a = __builtin_assume_aligned(a, 1ULL << 63);
return a[0];
}
@@ -43,6 +44,28 @@ int test8(int *a, int j) {
return a[0];
}
+int test9(int *a) {
+ a = __builtin_assume_aligned(a, 1ULL << 31); // no-warning
+ return a[0];
+}
+
+#ifdef SIZE_T_64
+int test10(int *a) {
+ a = __builtin_assume_aligned(a, 1ULL << 63); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
+ return a[0];
+}
+
+int test11(int *a) {
+ a = __builtin_assume_aligned(a, 1ULL << 32); // no-warning
+ return a[0];
+}
+
+int test12(int *a) {
+ a = __builtin_assume_aligned(a, 1ULL << 33); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
+ return a[0];
+}
+#endif
+
void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
@@ -58,8 +81,3 @@ void *test_no_fn_proto() __attribute__((assume_aligned(32, 73))); // no-warning
void *test_no_fn_proto() __attribute__((assume_aligned)); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
void *test_no_fn_proto() __attribute__((assume_aligned())); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
void *test_no_fn_proto() __attribute__((assume_aligned(32, 45, 37))); // expected-error {{'assume_aligned' attribute takes no more than 2 arguments}}
-
-int pr43638(int *a) {
- a = __builtin_assume_aligned(a, 8589934592); // expected-warning {{requested alignment must be 4294967296 bytes or smaller; maximum alignment assumed}}
- return a[0];
-}
More information about the cfe-commits
mailing list