void fn0 (int n) { p = __builtin_alloca_with_align (n, SIZE_MAX); /* { dg-error "39:must be a constant integer" } */ p = __builtin_alloca_with_align (n, MAX); /* { dg-error "39:must be a constant integer" } */ p = __builtin_alloca_with_align (n, MAX2); /* { dg-error "39:must be a constant integer" } */ p = __builtin_alloca_with_align (n, FIVE); /* { dg-error "39:must be a constant integer" } */ }
/* Integer alignment that's not a constant expression must be rejected. */ void test_arg2_non_const (int n, int a1) { extern const int a2; static const int a3 = CHAR_BIT; static volatile const int a4 = CHAR_BIT; p = __builtin_alloca_with_align (n, a1); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, a2); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, a3); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, a4); /* { dg-error "must be a constant integer" } */ }
void fn0 (int n) { p = __builtin_alloca_with_align (n, 6); /* { dg-error "39:must be a constant integer" } */ r += __builtin_isfinite (0); /* { dg-error "28:non-floating-point argument in call" } */ r += __builtin_isinf (0); /* { dg-error "25:non-floating-point argument in call" } */ r += __builtin_isinf_sign (0); /* { dg-error "30:non-floating-point argument in call" } */ r += __builtin_isnan (0); /* { dg-error "25:non-floating-point argument in call" } */ r += __builtin_isnormal (0); /* { dg-error "28:non-floating-point argument in call" } */ r += __builtin_signbit (0); /* { dg-error "27:non-floating-point argument in call" } */ r += __builtin_isgreater (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ r += __builtin_isgreaterequal (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ r += __builtin_isless (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ r += __builtin_islessequal (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ r += __builtin_islessgreater (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ r += __builtin_isunordered (0, 0); /* { dg-error "8:non-floating-point arguments in call to function" } */ r += __builtin_fpclassify (1, 2, n, 4, 5, n); /* { dg-error "36:non-const integer argument 3 in call" } */ r += __builtin_fpclassify (1, 2, 3, 4, 5, 6); /* { dg-error "45:non-floating-point argument in call" } */ d = __builtin_assume_aligned (p, n, p); /* { dg-error "39:non-integer argument 3 in call" } */ b = __builtin_add_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */ b = __builtin_add_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */ b = __builtin_sub_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */ b = __builtin_sub_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */ b = __builtin_mul_overflow (n, *d, &r); /* { dg-error "34:argument 2 in call to function" } */ b = __builtin_mul_overflow (n, 5, d); /* { dg-error "37:argument 3 in call" } */ }
void foo2 (__SIZE_TYPE__ len) { // Test that a direct call to __builtin_alloca_with_align is not confused // with a VLA. void *p = __builtin_alloca_with_align (len, 8); // { dg-warning "unbounded use of 'alloca'" } useit (p); }
/* Non-integer alignments must be rejected. */ void test_arg2_non_int (int n) { /* Verify the full text of the diagnostic just once. */ p = __builtin_alloca_with_align (n, 0.0); /* { dg-error "second argument to function .__builtin_alloca_with_align. must be a constant integer power of 2 between .8. and " } */ /* Disable diagnostic complaining about converting void* to int that preempts the "constant integer expression" error. */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wint-conversion" p = __builtin_alloca_with_align (n, (void*)0); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, ""); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, L""); /* { dg-error "must be a constant integer" } */ #pragma GCC diagnostic pop }
/* Constant integer alignment that's not a power of 2 positive multiple of CHAR_BIT less than (1LLU << 32) must be rejected. */ void test_arg2_non_pow2 (int n) { p = __builtin_alloca_with_align (n, 0); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 1); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 2); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 3); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 4); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 5); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 6); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 7); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 9); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 10); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 11); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 12); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 13); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 14); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 15); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 17); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 31); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 33); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 63); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, 65); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, SIZE_MAX); /* { dg-error "must be a constant integer" } */ p = __builtin_alloca_with_align (n, MAX_X_2); /* { dg-error "must be a constant integer" } */ }
/* Verify that valid __builtin_alloca_with_align expressions are accepted. */ void test_valid (int n) { enum { A1 = CHAR_BIT * 1, A2 = CHAR_BIT * 2, A4 = CHAR_BIT * 4, A8 = CHAR_BIT * 8, A16 = CHAR_BIT * 16, A32 = CHAR_BIT * 32 }; /* Valid alignments are power of 2 positive multiples of CHAR_BIT. */ p = __builtin_alloca_with_align (n, CHAR_BIT * 1); p = __builtin_alloca_with_align (n, CHAR_BIT * 2); p = __builtin_alloca_with_align (n, CHAR_BIT * 4); p = __builtin_alloca_with_align (n, CHAR_BIT * 8); p = __builtin_alloca_with_align (n, CHAR_BIT * 16); p = __builtin_alloca_with_align (n, CHAR_BIT * 32); p = __builtin_alloca_with_align (n, A1); p = __builtin_alloca_with_align (n, A2); p = __builtin_alloca_with_align (n, A4); p = __builtin_alloca_with_align (n, A8); p = __builtin_alloca_with_align (n, A16); p = __builtin_alloca_with_align (n, A32); }
// CHECK-LABEL: define dso_local void @test_alloca_with_align( void test_alloca_with_align(int n) { capture(__builtin_alloca_with_align(n, 64)); // CHECK: %[[arg:.*]] = alloca i8, i32 %{{.*}}, align 8 // CHECK: call void @capture(i8* %[[arg]]) }