mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-17 22:00:41 +00:00

Libc++ needs to know when aligned allocation is supported by clang, but is otherwise unavailable at link time. Otherwise, libc++ will incorrectly end up generating calls to `__builtin_operator_new`/`__builtin_operator_delete` with alignment arguments. This patch implements the following changes: * The `__cpp_aligned_new` feature test macro to no longer be defined when aligned allocation is otherwise enabled but unavailable. * The Darwin driver no longer passes `-faligned-alloc-unavailable` when the user manually specifies `-faligned-allocation` or `-fno-aligned-allocation`. * Instead of a warning Clang now generates a hard error when an aligned allocation or deallocation function is referenced but unavailable. Patch by Eric Fiselier. Reviewers: rsmith, vsapsai, erik.pilkington, ahatanak, dexonsmith Reviewed By: rsmith Subscribers: Quuxplusone, cfe-commits Differential Revision: https://reviews.llvm.org/D45015 llvm-svn: 338934
24 lines
807 B
C++
24 lines
807 B
C++
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++17 -verify %s \
|
|
// RUN: -DEXPECT_DEFINED
|
|
//
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++17 -verify %s \
|
|
// RUN: -faligned-alloc-unavailable
|
|
//
|
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++17 -verify %s \
|
|
// RUN: -faligned-allocation -faligned-alloc-unavailable
|
|
|
|
// Test that __cpp_aligned_new is not defined when CC1 is passed
|
|
// -faligned-alloc-unavailable by the Darwin driver, even when aligned
|
|
// allocation is actually enabled.
|
|
|
|
// expected-no-diagnostics
|
|
#ifdef EXPECT_DEFINED
|
|
# ifndef __cpp_aligned_new
|
|
# error "__cpp_aligned_new" should be defined
|
|
# endif
|
|
#else
|
|
# ifdef __cpp_aligned_new
|
|
# error "__cpp_aligned_new" should not be defined
|
|
# endif
|
|
#endif
|