llvm-project/clang/test/Sema/builtin-assume-aligned-downgrade.c
Oliver Stannard ecdc5289af
[Clang] Fix crash in __builtin_assume_aligned (#114217)
The CodeGen for __builtin_assume_aligned assumes that the first argument
is a pointer, so crashes if the int-conversion error is downgraded or
disabled. Emit a non-downgradable error if the argument is not a
pointer, like we currently do for __builtin_launder.

Fixes #110914.
2024-12-19 10:34:56 +00:00

10 lines
505 B
C

// RUN: %clang_cc1 -fsyntax-only -Wno-int-conversion -triple x86_64-linux -verify %s
// Check that the pointer->int conversion error is not downgradable for the
// pointer argument to __builtin_assume_aligned.
int test(int *a, int b) {
a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{non-pointer argument to '__builtin_assume_aligned' is not allowed}}
int *y = __builtin_assume_aligned(1, 1); // expected-error {{non-pointer argument to '__builtin_assume_aligned' is not allowed}}
}