Index: clang/lib/Driver/ToolChains/ZOS.h =================================================================== --- clang/lib/Driver/ToolChains/ZOS.h +++ clang/lib/Driver/ToolChains/ZOS.h @@ -27,6 +27,10 @@ bool isPICDefaultForced() const override { return false; } bool IsIntegratedAssemblerDefault() const override { return true; } + + void addClangTargetOptions( + const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadingKind) const override; }; } // end namespace toolchains Index: clang/lib/Driver/ToolChains/ZOS.cpp =================================================================== --- clang/lib/Driver/ToolChains/ZOS.cpp +++ clang/lib/Driver/ToolChains/ZOS.cpp @@ -21,3 +21,13 @@ : ToolChain(D, Triple, Args) {} ZOS::~ZOS() {} + +void ZOS::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadKind) const { + // Pass "-faligned-alloc-unavailable" only when the user hasn't manually + // enabled or disabled aligned allocations. + if (!DriverArgs.hasArgNoClaim(options::OPT_faligned_allocation, + options::OPT_fno_aligned_allocation)) + CC1Args.push_back("-faligned-alloc-unavailable"); +} Index: clang/test/Driver/unavailable_aligned_allocation.cpp =================================================================== --- clang/test/Driver/unavailable_aligned_allocation.cpp +++ clang/test/Driver/unavailable_aligned_allocation.cpp @@ -22,6 +22,9 @@ // RUN: -c -### %s 2>&1 \ // RUN: | FileCheck %s -check-prefix=UNAVAILABLE // +// RUN: %clang -target s390x-ibm-zos -c -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=UNAVAILABLE + // UNAVAILABLE: "-faligned-alloc-unavailable" // RUN: %clang -target x86_64-apple-macosx10.14 -c -### %s 2>&1 \ @@ -59,5 +62,11 @@ // // RUN: %clang -target x86_64-apple-macosx10.13 -fno-aligned-allocation -c -### %s 2>&1 \ // RUN: | FileCheck %s -check-prefix=AVAILABLE +// +// RUN: %clang -target s390x-ibm-zos -faligned-allocation -c -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=AVAILABLE +// +// RUN: %clang -target s390x-ibm-zos -fno-aligned-allocation -c -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=AVAILABLE // AVAILABLE-NOT: "-faligned-alloc-unavailable" Index: clang/test/Lexer/aligned-allocation.cpp =================================================================== --- clang/test/Lexer/aligned-allocation.cpp +++ clang/test/Lexer/aligned-allocation.cpp @@ -6,10 +6,19 @@ // // RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions -std=c++17 -verify %s \ // RUN: -faligned-allocation -faligned-alloc-unavailable +// +// RUN: %clang_cc1 -triple s390x-ibm-zos -fexceptions -std=c++17 -verify %s \ +// RUN: -DEXPECT_DEFINED +// +// RUN: %clang_cc1 -triple s390x-ibm-zos -fexceptions -std=c++17 -verify %s \ +// RUN: -faligned-alloc-unavailable +// +// RUN: %clang_cc1 -triple s390x-ibm-zos -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. +// -faligned-alloc-unavailable by the Darwin and the z/OS driver, even when +// aligned allocation is actually enabled. // expected-no-diagnostics #ifdef EXPECT_DEFINED