Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -338,6 +338,9 @@ - Fix crash when attempting to perform parenthesized initialization of an aggregate with a base class with only non-public constructors. (`#62296 `_) +- Fix crash when attempting to pass a non-pointer type as first argument of + ``__builtin_assume_aligned``. + (`#62305 `_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -7979,8 +7979,9 @@ { ExprResult FirstArgResult = DefaultFunctionArrayLvalueConversion(FirstArg); - if (FirstArgResult.isInvalid()) + if (checkBuiltinArgument(*this, TheCall, 0)) return true; + /// In-place updation of FirstArg by checkBuiltinArgument is ignored. TheCall->setArg(0, FirstArgResult.get()); } Index: clang/test/Sema/builtin-assume-aligned.c =================================================================== --- clang/test/Sema/builtin-assume-aligned.c +++ clang/test/Sema/builtin-assume-aligned.c @@ -71,6 +71,26 @@ return a[0]; } +int test14(int *a, int b) { + a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *}} + return a[0]; +} + +int test15(int *b) { + int arr[3] = {1, 2, 3}; + b = (int *)__builtin_assume_aligned(arr, 32); + return b[0]; +} + +int val(int x) { + return x; +} + +int test16(int *b) { + b = (int*)__builtin_assume_aligned(val, 32); + return b[0]; +} + 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