Index: lib/Frontend/InitPreprocessor.cpp =================================================================== --- lib/Frontend/InitPreprocessor.cpp +++ lib/Frontend/InitPreprocessor.cpp @@ -1056,6 +1056,9 @@ Builder.defineMacro("__GLIBCXX_BITSIZE_INT_N_0", "128"); } + if (!LangOpts.AlignedAllocation || LangOpts.AlignedAllocationUnavailable) + Builder.defineMacro("__ALIGNED_ALLOCATION_UNAVAILABLE__"); + // Get other target #defines. TI.getTargetDefines(LangOpts, Builder); } Index: test/Preprocessor/predefined-macros.c =================================================================== --- test/Preprocessor/predefined-macros.c +++ test/Preprocessor/predefined-macros.c @@ -271,3 +271,20 @@ // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \ // RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR // CHECK-SPIR: #define __IMAGE_SUPPORT__ 1 + + +// RUN: %clang_cc1 %s -x c++ -E -dM -faligned-allocation \ +// RUN: | FileCheck %s -check-prefix=CHECK-ALIGNED-ALLOC-AVAILABLE +// RUN: %clang_cc1 %s -x c++ -E -dM -std=c++17 \ +// RUN: | FileCheck %s -check-prefix=CHECK-ALIGNED-ALLOC-AVAILABLE + +// CHECK-ALIGNED-ALLOC-AVAILABLE-NOT: __ALIGNED_ALLOCATION_UNAVAILABLE__ + +// RUN: %clang_cc1 %s -x c++ -E -dM -std=c++03 \ +// RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ALIGNED-ALLOC-UNAVAILABLE +// RUN: %clang_cc1 %s -x c++ -E -dM -faligned-alloc-unavailable \ +// RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ALIGNED-ALLOC-UNAVAILABLE +// RUN: %clang_cc1 %s -x c++ -E -dM -faligned-allocation -faligned-alloc-unavailable \ +// RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ALIGNED-ALLOC-UNAVAILABLE + +// CHECK-ALIGNED-ALLOC-UNAVAILABLE: #define __ALIGNED_ALLOCATION_UNAVAILABLE__ 1