Author: rsmith Date: Fri Sep 30 17:41:36 2016 New Revision: 282974 URL: http://llvm.org/viewvc/llvm-project?rev=282974&view=rev Log: P0035R4: add predefined __STDCPP_DEFAULT_NEW_ALIGNMENT__ macro. By default, we assume that ::operator new provides no more alignment than is necessary for any primitive type, except when we're on a GNU OS, where glibc's malloc guarantees to provide 64-bit alignment on 32-bit systems and 128-bit alignment on 64-bit systems. This can be controlled by the command-line -fnew-alignment flag.
Added: cfe/trunk/test/CXX/cpp/cpp.predefined/p1.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Sep 30 17:41:36 2016 @@ -114,6 +114,8 @@ def err_fe_no_pch_in_dir : Error< "no suitable precompiled header file found in directory '%0'">; def err_fe_action_not_available : Error< "action %0 not compiled in">; +def err_fe_invalid_alignment : Error< + "invalid value '%1' in '%0'; alignment must be a power of 2">; def warn_fe_serialized_diag_merge_failure : Warning< "unable to merge a subprocess's serialized diagnostics">, Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/LangOptions.def (original) +++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Sep 30 17:41:36 2016 @@ -195,7 +195,9 @@ LANGOPT(CUDAHostDeviceConstexpr, 1, 1, " LANGOPT(CUDADeviceFlushDenormalsToZero, 1, 0, "flushing denormals to zero") LANGOPT(CUDADeviceApproxTranscendentals, 1, 0, "using approximate transcendental functions") -LANGOPT(SizedDeallocation , 1, 0, "enable sized deallocation functions") +LANGOPT(SizedDeallocation , 1, 0, "sized deallocation") +LANGOPT(AlignedAllocation , 1, 0, "aligned allocation") +LANGOPT(NewAlignOverride , 32, 0, "maximum alignment guaranteed by '::operator new(size_t)'") LANGOPT(ConceptsTS , 1, 0, "enable C++ Extensions for Concepts") BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision") BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd records") Modified: cfe/trunk/include/clang/Basic/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/TargetInfo.h (original) +++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Sep 30 17:41:36 2016 @@ -76,6 +76,7 @@ protected: unsigned short MaxVectorAlign; unsigned short MaxTLSAlign; unsigned short SimdDefaultAlign; + unsigned short NewAlign; std::unique_ptr<llvm::DataLayout> DataLayout; const char *MCountName; const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat, @@ -353,6 +354,13 @@ public: /// unless its alignment is explicitly reduced via attributes. unsigned getMinGlobalAlign() const { return MinGlobalAlign; } + /// Return the largest alignment for which a suitably-sized allocation with + /// '::operator new(size_t)' is guaranteed to produce a correctly-aligned + /// pointer. + unsigned getNewAlign() const { + return NewAlign ? NewAlign : std::max(LongDoubleAlign, LongLongAlign); + } + /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in /// bits. unsigned getWCharWidth() const { return getTypeWidth(WCharType); } Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Fri Sep 30 17:41:36 2016 @@ -1046,6 +1046,17 @@ def fno_application_extension : Flag<["- def fsized_deallocation : Flag<["-"], "fsized-deallocation">, Flags<[CC1Option]>, HelpText<"Enable C++14 sized global deallocation functions">, Group<f_Group>; def fno_sized_deallocation: Flag<["-"], "fno-sized-deallocation">, Group<f_Group>; +def faligned_allocation : Flag<["-"], "faligned-allocation">, Flags<[CC1Option]>, + HelpText<"Enable C++17 aligned allocation functions">, Group<f_Group>; +def fno_aligned_allocation: Flag<["-"], "fno-aligned-allocation">, + Group<f_Group>, Flags<[CC1Option]>; +def fnew_alignment_EQ : Joined<["-"], "fnew-alignment=">, + HelpText<"Specifies the largest alignment guaranteed by '::operator new(size_t)'">, + MetaVarName<"<align>">, Group<f_Group>, Flags<[CC1Option]>; +def : Separate<["-"], "fnew-alignment">, Alias<fnew_alignment_EQ>; +def : Flag<["-"], "faligned-new">, Alias<faligned_allocation>; +def : Flag<["-"], "fno-aligned-new">, Alias<fno_aligned_allocation>; +def faligned_new_EQ : Joined<["-"], "faligned-new=">; def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Use GC exclusively for Objective-C related memory management">; Modified: cfe/trunk/lib/Basic/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/lib/Basic/TargetInfo.cpp (original) +++ cfe/trunk/lib/Basic/TargetInfo.cpp Fri Sep 30 17:41:36 2016 @@ -39,6 +39,13 @@ TargetInfo::TargetInfo(const llvm::Tripl SuitableAlign = 64; DefaultAlignForAttributeAligned = 128; MinGlobalAlign = 0; + // From the glibc documentation, on GNU systems, malloc guarantees 16-byte + // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See + // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html + if (T.isGNUEnvironment()) + NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0; + else + NewAlign = 0; // Infer from basic type alignment. HalfWidth = 16; HalfAlign = 16; FloatWidth = 32; @@ -320,6 +327,9 @@ void TargetInfo::adjust(const LangOption FloatFormat = &llvm::APFloat::IEEEsingle; LongDoubleFormat = &llvm::APFloat::IEEEquad; } + + if (Opts.NewAlignOverride) + NewAlign = Opts.NewAlignOverride * getCharWidth(); } bool TargetInfo::initFeatureMap( Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Fri Sep 30 17:41:36 2016 @@ -1768,6 +1768,7 @@ public: LongLongWidth = HostTarget->getLongLongWidth(); LongLongAlign = HostTarget->getLongLongAlign(); MinGlobalAlign = HostTarget->getMinGlobalAlign(); + NewAlign = HostTarget->getNewAlign(); DefaultAlignForAttributeAligned = HostTarget->getDefaultAlignForAttributeAligned(); SizeType = HostTarget->getSizeType(); Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep 30 17:41:36 2016 @@ -5821,6 +5821,24 @@ void Clang::ConstructJob(Compilation &C, options::OPT_fno_sized_deallocation, false)) CmdArgs.push_back("-fsized-deallocation"); + // -faligned-allocation is on by default in C++17 onwards and otherwise off + // by default. + if (Arg *A = Args.getLastArg(options::OPT_faligned_allocation, + options::OPT_fno_aligned_allocation, + options::OPT_faligned_new_EQ)) { + if (A->getOption().matches(options::OPT_fno_aligned_allocation)) + CmdArgs.push_back("-fno-aligned-allocation"); + else + CmdArgs.push_back("-faligned-allocation"); + } + + // The default new alignment can be specified using a dedicated option or via + // a GCC-compatible option that also turns on aligned allocation. + if (Arg *A = Args.getLastArg(options::OPT_fnew_alignment_EQ, + options::OPT_faligned_new_EQ)) + CmdArgs.push_back( + Args.MakeArgString(Twine("-fnew-alignment=") + A->getValue())); + // -fconstant-cfstrings is default, and may be subject to argument translation // on Darwin. if (!Args.hasFlag(options::OPT_fconstant_cfstrings, Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Sep 30 17:41:36 2016 @@ -1625,6 +1625,8 @@ void CompilerInvocation::setLangDefaults Opts.GNUKeywords = Opts.GNUMode; Opts.CXXOperatorNames = Opts.CPlusPlus; + Opts.AlignedAllocation = Opts.CPlusPlus1z; + Opts.DollarIdents = !Opts.AsmPreprocessor; } @@ -1937,6 +1939,17 @@ static void ParseLangArgs(LangOptions &O getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs); Opts.NoMathBuiltin = Args.hasArg(OPT_fno_math_builtin); Opts.SizedDeallocation = Args.hasArg(OPT_fsized_deallocation); + Opts.AlignedAllocation = + Args.hasFlag(OPT_faligned_allocation, OPT_fno_aligned_allocation, + Opts.AlignedAllocation); + Opts.NewAlignOverride = + getLastArgIntValue(Args, OPT_fnew_alignment_EQ, 0, Diags); + if (Opts.NewAlignOverride && !llvm::isPowerOf2_32(Opts.NewAlignOverride)) { + Arg *A = Args.getLastArg(OPT_fnew_alignment_EQ); + Diags.Report(diag::err_fe_invalid_alignment) << A->getAsString(Args) + << A->getValue(); + Opts.NewAlignOverride = 0; + } Opts.ConceptsTS = Args.hasArg(OPT_fconcepts_ts); Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions); Opts.AccessControl = !Args.hasArg(OPT_fno_access_control); Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri Sep 30 17:41:36 2016 @@ -392,6 +392,15 @@ static void InitializeStandardPredefined // C++ translation unit. else Builder.defineMacro("__cplusplus", "199711L"); + + // C++1z [cpp.predefined]p1: + // An integer literal of type std::size_t whose value is the alignment + // guaranteed by a call to operator new(std::size_t) + // + // We provide this in all language modes, since it seems generally useful. + Builder.defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__", + Twine(TI.getNewAlign() / TI.getCharWidth()) + + TI.getTypeConstantSuffix(TI.getSizeType())); } // In C11 these are environment macros. In C++11 they are only defined Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Sep 30 17:41:36 2016 @@ -2340,7 +2340,7 @@ void Sema::DeclareGlobalNewDelete() { nullptr); getStdBadAlloc()->setImplicit(true); } - if (!StdAlignValT && getLangOpts().CPlusPlus1z) { + if (!StdAlignValT && getLangOpts().AlignedAllocation) { // The "std::align_val_t" enum class has not yet been declared, so build it // implicitly. auto *AlignValT = EnumDecl::Create( @@ -2365,7 +2365,7 @@ void Sema::DeclareGlobalNewDelete() { // Create up to four variants of the function (sized/aligned). bool HasSizedVariant = getLangOpts().SizedDeallocation && (Kind == OO_Delete || Kind == OO_Array_Delete); - bool HasAlignedVariant = getLangOpts().CPlusPlus1z; + bool HasAlignedVariant = getLangOpts().AlignedAllocation; int NumSizeVariants = (HasSizedVariant ? 2 : 1); int NumAlignVariants = (HasAlignedVariant ? 2 : 1); Added: cfe/trunk/test/CXX/cpp/cpp.predefined/p1.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/cpp/cpp.predefined/p1.cpp?rev=282974&view=auto ============================================================================== --- cfe/trunk/test/CXX/cpp/cpp.predefined/p1.cpp (added) +++ cfe/trunk/test/CXX/cpp/cpp.predefined/p1.cpp Fri Sep 30 17:41:36 2016 @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -std=c++1z %s -verify -triple x86_64-linux-gnu -DALIGN=16 +// RUN: %clang_cc1 -std=c++1z %s -verify -fnew-alignment=2 -DALIGN=2 +// RUN: %clang_cc1 -std=c++1z %s -verify -fnew-alignment=256 -DALIGN=256 + +// expected-no-diagnostics + +#if ALIGN != __STDCPP_DEFAULT_NEW_ALIGNMENT__ +#error wrong value for __STDCPP_DEFAULT_NEW_ALIGNMENT__ +#endif Modified: cfe/trunk/test/Preprocessor/init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=282974&r1=282973&r2=282974&view=diff ============================================================================== --- cfe/trunk/test/Preprocessor/init.c (original) +++ cfe/trunk/test/Preprocessor/init.c Fri Sep 30 17:41:36 2016 @@ -247,6 +247,7 @@ // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64 %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64 %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=arm64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64 -check-prefix AARCH64-CXX %s // // AARCH64:#define _LP64 1 // AARCH64-NOT:#define __AARCH64EB__ 1 @@ -393,6 +394,7 @@ // AARCH64:#define __SIZE_MAX__ 18446744073709551615UL // AARCH64:#define __SIZE_TYPE__ long unsigned int // AARCH64:#define __SIZE_WIDTH__ 64 +// AARCH64-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // AARCH64:#define __UINT16_C_SUFFIX__ // AARCH64:#define __UINT16_MAX__ 65535 // AARCH64:#define __UINT16_TYPE__ unsigned short @@ -1206,6 +1208,7 @@ // AARCH64-DARWIN: #define __aarch64__ 1 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -match-full-lines -check-prefix ARM %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -match-full-lines -check-prefix ARM -check-prefix ARM-CXX %s // // ARM-NOT:#define _LP64 // ARM:#define __APCS_32__ 1 @@ -1351,6 +1354,7 @@ // ARM:#define __SIZE_MAX__ 4294967295U // ARM:#define __SIZE_TYPE__ unsigned int // ARM:#define __SIZE_WIDTH__ 32 +// ARM-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // ARM:#define __UINT16_C_SUFFIX__ // ARM:#define __UINT16_MAX__ 65535 // ARM:#define __UINT16_TYPE__ unsigned short @@ -2431,6 +2435,7 @@ // I386:#define i386 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck -match-full-lines -check-prefix I386-LINUX %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck -match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-CXX %s // // I386-LINUX-NOT:#define _LP64 // I386-LINUX:#define __BIGGEST_ALIGNMENT__ 16 @@ -2572,6 +2577,7 @@ // I386-LINUX:#define __SIZE_MAX__ 4294967295U // I386-LINUX:#define __SIZE_TYPE__ unsigned int // I386-LINUX:#define __SIZE_WIDTH__ 32 +// I386-LINUX-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // I386-LINUX:#define __UINT16_C_SUFFIX__ // I386-LINUX:#define __UINT16_MAX__ 65535 // I386-LINUX:#define __UINT16_TYPE__ unsigned short @@ -2618,6 +2624,7 @@ // I386-LINUX:#define i386 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-netbsd < /dev/null | FileCheck -match-full-lines -check-prefix I386-NETBSD %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=i386-netbsd < /dev/null | FileCheck -match-full-lines -check-prefix I386-NETBSD -check-prefix I386-NETBSD-CXX %s // // I386-NETBSD-NOT:#define _LP64 // I386-NETBSD:#define __BIGGEST_ALIGNMENT__ 16 @@ -2759,6 +2766,7 @@ // I386-NETBSD:#define __SIZE_MAX__ 4294967295U // I386-NETBSD:#define __SIZE_TYPE__ unsigned int // I386-NETBSD:#define __SIZE_WIDTH__ 32 +// I386-NETBSD-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U // I386-NETBSD:#define __UINT16_C_SUFFIX__ // I386-NETBSD:#define __UINT16_MAX__ 65535 // I386-NETBSD:#define __UINT16_TYPE__ unsigned short @@ -2818,7 +2826,8 @@ // I386-DECLSPEC: #define __declspec{{.*}} // -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MIPS32BE %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MIPS32BE -check-prefix MIPS32BE-C %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=mips-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MIPS32BE -check-prefix MIPS32BE-CXX %s // // MIPS32BE:#define MIPSEB 1 // MIPS32BE:#define _ABIO32 1 @@ -2973,8 +2982,9 @@ // MIPS32BE:#define __SIZE_MAX__ 4294967295U // MIPS32BE:#define __SIZE_TYPE__ unsigned int // MIPS32BE:#define __SIZE_WIDTH__ 32 +// MIPS32BE-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // MIPS32BE:#define __STDC_HOSTED__ 0 -// MIPS32BE:#define __STDC_VERSION__ 201112L +// MIPS32BE-C:#define __STDC_VERSION__ 201112L // MIPS32BE:#define __STDC__ 1 // MIPS32BE:#define __UINT16_C_SUFFIX__ // MIPS32BE:#define __UINT16_MAX__ 65535 @@ -3235,7 +3245,10 @@ // // RUN: %clang_cc1 -E -dM -ffreestanding \ // RUN: -triple=mips64-none-none -target-abi n32 < /dev/null \ -// RUN: | FileCheck -match-full-lines -check-prefix MIPSN32BE %s +// RUN: | FileCheck -match-full-lines -check-prefix MIPSN32BE -check-prefix MIPSN32BE-C %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding \ +// RUN: -triple=mips64-none-none -target-abi n32 < /dev/null \ +// RUN: | FileCheck -match-full-lines -check-prefix MIPSN32BE -check-prefix MIPSN32BE-CXX %s // // MIPSN32BE: #define MIPSEB 1 // MIPSN32BE: #define _ABIN32 2 @@ -3304,7 +3317,7 @@ // MIPSN32BE: #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 // MIPSN32BE: #define __GNUC_MINOR__ 2 // MIPSN32BE: #define __GNUC_PATCHLEVEL__ 1 -// MIPSN32BE: #define __GNUC_STDC_INLINE__ 1 +// MIPSN32BE-C: #define __GNUC_STDC_INLINE__ 1 // MIPSN32BE: #define __GNUC__ 4 // MIPSN32BE: #define __GXX_ABI_VERSION 1002 // MIPSN32BE: #define __ILP32__ 1 @@ -3424,10 +3437,11 @@ // MIPSN32BE: #define __SIZE_MAX__ 4294967295U // MIPSN32BE: #define __SIZE_TYPE__ unsigned int // MIPSN32BE: #define __SIZE_WIDTH__ 32 +// MIPSN32BE-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16U // MIPSN32BE: #define __STDC_HOSTED__ 0 // MIPSN32BE: #define __STDC_UTF_16__ 1 // MIPSN32BE: #define __STDC_UTF_32__ 1 -// MIPSN32BE: #define __STDC_VERSION__ 201112L +// MIPSN32BE-C: #define __STDC_VERSION__ 201112L // MIPSN32BE: #define __STDC__ 1 // MIPSN32BE: #define __UINT16_C_SUFFIX__ // MIPSN32BE: #define __UINT16_FMTX__ "hX" @@ -3846,6 +3860,7 @@ // MIPSN32EL: #define mips 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MIPS64BE %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=mips64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MIPS64BE -check-prefix MIPS64BE-CXX %s // // MIPS64BE:#define MIPSEB 1 // MIPS64BE:#define _ABI64 3 @@ -4001,6 +4016,7 @@ // MIPS64BE:#define __SIZE_MAX__ 18446744073709551615UL // MIPS64BE:#define __SIZE_TYPE__ long unsigned int // MIPS64BE:#define __SIZE_WIDTH__ 64 +// MIPS64BE-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // MIPS64BE:#define __UINT16_C_SUFFIX__ // MIPS64BE:#define __UINT16_MAX__ 65535 // MIPS64BE:#define __UINT16_TYPE__ unsigned short @@ -4489,6 +4505,7 @@ // MIPS-XXR6:#define __mips_nan2008 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MSP430 %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MSP430 -check-prefix MSP430-CXX %s // // MSP430:#define MSP430 1 // MSP430-NOT:#define _LP64 @@ -4630,6 +4647,7 @@ // MSP430:#define __SIZE_MAX__ 65535U // MSP430:#define __SIZE_TYPE__ unsigned int // MSP430:#define __SIZE_WIDTH__ 16 +// MSP430-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // MSP430:#define __UINT16_C_SUFFIX__ U // MSP430:#define __UINT16_MAX__ 65535U // MSP430:#define __UINT16_TYPE__ unsigned short @@ -4674,6 +4692,7 @@ // MSP430:#define __clang__ 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=nvptx-none-none < /dev/null | FileCheck -match-full-lines -check-prefix NVPTX32 %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=nvptx-none-none < /dev/null | FileCheck -match-full-lines -check-prefix NVPTX32 -check-prefix NVPTX32-CXX %s // // NVPTX32-NOT:#define _LP64 // NVPTX32:#define __BIGGEST_ALIGNMENT__ 8 @@ -4818,6 +4837,7 @@ // NVPTX32:#define __SIZE_MAX__ 4294967295U // NVPTX32:#define __SIZE_TYPE__ unsigned int // NVPTX32:#define __SIZE_WIDTH__ 32 +// NVPTX32-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // NVPTX32:#define __UINT16_C_SUFFIX__ // NVPTX32:#define __UINT16_MAX__ 65535 // NVPTX32:#define __UINT16_TYPE__ unsigned short @@ -4861,6 +4881,7 @@ // NVPTX32:#define __WINT_WIDTH__ 32 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=nvptx64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix NVPTX64 %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=nvptx64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix NVPTX64 -check-prefix NVPTX64-CXX %s // // NVPTX64:#define _LP64 1 // NVPTX64:#define __BIGGEST_ALIGNMENT__ 8 @@ -5005,6 +5026,7 @@ // NVPTX64:#define __SIZE_MAX__ 18446744073709551615UL // NVPTX64:#define __SIZE_TYPE__ long unsigned int // NVPTX64:#define __SIZE_WIDTH__ 64 +// NVPTX64-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL // NVPTX64:#define __UINT16_C_SUFFIX__ // NVPTX64:#define __UINT16_MAX__ 65535 // NVPTX64:#define __UINT16_TYPE__ unsigned short @@ -5048,6 +5070,7 @@ // NVPTX64:#define __WINT_WIDTH__ 32 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-none-none -target-cpu 603e < /dev/null | FileCheck -match-full-lines -check-prefix PPC603E %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=powerpc-none-none -target-cpu 603e < /dev/null | FileCheck -match-full-lines -check-prefix PPC603E-CXX %s // // PPC603E:#define _ARCH_603 1 // PPC603E:#define _ARCH_603E 1 @@ -5197,6 +5220,7 @@ // PPC603E:#define __SIZE_MAX__ 4294967295UL // PPC603E:#define __SIZE_TYPE__ long unsigned int // PPC603E:#define __SIZE_WIDTH__ 32 +// PPC603E-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // PPC603E:#define __UINT16_C_SUFFIX__ // PPC603E:#define __UINT16_MAX__ 65535 // PPC603E:#define __UINT16_TYPE__ unsigned short @@ -5242,6 +5266,7 @@ // PPC603E:#define __ppc__ 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr7 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC64 %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr7 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC64 -check-prefix PPC64-CXX %s // // PPC64:#define _ARCH_PPC 1 // PPC64:#define _ARCH_PPC64 1 @@ -5397,6 +5422,7 @@ // PPC64:#define __SIZE_MAX__ 18446744073709551615UL // PPC64:#define __SIZE_TYPE__ long unsigned int // PPC64:#define __SIZE_WIDTH__ 64 +// PPC64-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // PPC64:#define __UINT16_C_SUFFIX__ // PPC64:#define __UINT16_MAX__ 65535 // PPC64:#define __UINT16_TYPE__ unsigned short @@ -6662,6 +6688,7 @@ // AMDGPU:#define cl_khr_local_int32_extended_atomics 1 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X -check-prefix S390X-CXX %s // // S390X:#define __BIGGEST_ALIGNMENT__ 8 // S390X:#define __CHAR16_TYPE__ unsigned short @@ -6798,6 +6825,7 @@ // S390X:#define __SIZEOF_WINT_T__ 4 // S390X:#define __SIZE_TYPE__ long unsigned int // S390X:#define __SIZE_WIDTH__ 64 +// S390X-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL // S390X:#define __UINT16_C_SUFFIX__ // S390X:#define __UINT16_MAX__ 65535 // S390X:#define __UINT16_TYPE__ unsigned short @@ -6846,6 +6874,8 @@ // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-rtems-elf < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-netbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT -check-prefix SPARC-DEFAULT-CXX %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=sparc-none-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-NETOPENBSD -check-prefix SPARC-NETOPENBSD-CXX %s // // SPARC-NOT:#define _LP64 // SPARC:#define __BIGGEST_ALIGNMENT__ 8 @@ -6993,6 +7023,8 @@ // SPARC-NETOPENBSD:#define __SIZE_MAX__ 4294967295UL // SPARC-NETOPENBSD:#define __SIZE_TYPE__ long unsigned int // SPARC:#define __SIZE_WIDTH__ 32 +// SPARC-DEFAULT-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U +// SPARC-NETOPENBSD-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL // SPARC:#define __UINT16_C_SUFFIX__ // SPARC:#define __UINT16_MAX__ 65535 // SPARC:#define __UINT16_TYPE__ unsigned short @@ -7043,6 +7075,7 @@ // SPARC:#define sparc 1 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=tce-none-none < /dev/null | FileCheck -match-full-lines -check-prefix TCE %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=tce-none-none < /dev/null | FileCheck -match-full-lines -check-prefix TCE -check-prefix TCE-CXX %s // // TCE-NOT:#define _LP64 // TCE:#define __BIGGEST_ALIGNMENT__ 4 @@ -7169,6 +7202,7 @@ // TCE:#define __SIZE_MAX__ 4294967295U // TCE:#define __SIZE_TYPE__ unsigned int // TCE:#define __SIZE_WIDTH__ 32 +// TCE-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U // TCE:#define __TCE_V1__ 1 // TCE:#define __TCE__ 1 // TCE:#define __UINT16_C_SUFFIX__ @@ -7210,6 +7244,7 @@ // TCE:#define tce 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix X86_64 %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix X86_64 -check-prefix X86_64-CXX %s // // X86_64:#define _LP64 1 // X86_64-NOT:#define _LP32 1 @@ -7358,6 +7393,7 @@ // X86_64:#define __SSE2__ 1 // X86_64:#define __SSE_MATH__ 1 // X86_64:#define __SSE__ 1 +// X86_64-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // X86_64:#define __UINT16_C_SUFFIX__ // X86_64:#define __UINT16_MAX__ 65535 // X86_64:#define __UINT16_TYPE__ unsigned short @@ -7412,6 +7448,7 @@ // X86_64H:#define __x86_64h__ 1 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-none-none-gnux32 < /dev/null | FileCheck -match-full-lines -check-prefix X32 %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-none-none-gnux32 < /dev/null | FileCheck -match-full-lines -check-prefix X32 -check-prefix X32-CXX %s // // X32:#define _ILP32 1 // X32-NOT:#define _LP64 1 @@ -7560,6 +7597,7 @@ // X32:#define __SSE2__ 1 // X32:#define __SSE_MATH__ 1 // X32:#define __SSE__ 1 +// X32-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16U // X32:#define __UINT16_C_SUFFIX__ // X32:#define __UINT16_MAX__ 65535 // X32:#define __UINT16_TYPE__ unsigned short @@ -8460,6 +8498,12 @@ // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s // ANDROID:#define __ANDROID__ 1 // +// RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s +// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U +// +// RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s +// X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL +// // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s // LANAI: #define __lanai__ 1 // _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits