summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2019-01-15 21:24:55 +0000
committerReid Kleckner <rnk@google.com>2019-01-15 21:24:55 +0000
commita86f15c281c9297b1c1151c054246b039f52142f (patch)
tree66861e78a1333ced5618ebc0ca73b5ad70df3164
parente8790ce586220bc615139e406cde9545304d0a63 (diff)
[clang-cl] Alias /Zc:alignedNew[-] to -f[no-]aligned-allocation
Implements PR40180. clang-cl has one minor behavior difference with cl with this change. Clang allows the user to enable the C++17 feature of aligned allocation without enabling all of C++17, but MSVC will not call the aligned allocation overloads unless -std:c++17 is passed. While our behavior is technically incompatible, it would require making driver mode specific changes to match MSVC precisely, and clang's behavior is useful because it allows people to experiment with new C++17 features individually. Therefore, I plan to leave it as is. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351249 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Driver/CLCompatOptions.td6
-rw-r--r--test/Driver/cl-zc.cpp6
2 files changed, 12 insertions, 0 deletions
diff --git a/include/clang/Driver/CLCompatOptions.td b/include/clang/Driver/CLCompatOptions.td
index b09ea41049..3e0dc2db7d 100644
--- a/include/clang/Driver/CLCompatOptions.td
+++ b/include/clang/Driver/CLCompatOptions.td
@@ -207,6 +207,12 @@ def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">,
def _SLASH_Zc_sizedDealloc_ : CLFlag<"Zc:sizedDealloc-">,
HelpText<"Disable C++14 sized global deallocation functions">,
Alias<fno_sized_deallocation>;
+def _SLASH_Zc_alignedNew : CLFlag<"Zc:alignedNew">,
+ HelpText<"Enable C++17 aligned allocation functions">,
+ Alias<faligned_allocation>;
+def _SLASH_Zc_alignedNew_ : CLFlag<"Zc:alignedNew-">,
+ HelpText<"Disable C++17 aligned allocation functions">,
+ Alias<fno_aligned_allocation>;
def _SLASH_Zc_strictStrings : CLFlag<"Zc:strictStrings">,
HelpText<"Treat string literals as const">, Alias<W_Joined>,
AliasArgs<["error=c++11-compat-deprecated-writable-strings"]>;
diff --git a/test/Driver/cl-zc.cpp b/test/Driver/cl-zc.cpp
index 4414eb6ebb..cf7734875e 100644
--- a/test/Driver/cl-zc.cpp
+++ b/test/Driver/cl-zc.cpp
@@ -18,6 +18,12 @@
// RUN: %clang_cl /c -### /Zc:sizedDealloc- -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-OFF %s
// SIZED-DEALLOC-OFF-NOT: "-fsized-deallocation"
+// RUN: %clang_cl /c /std:c++17 -### /Zc:alignedNew -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-ON %s
+// ALIGNED-NEW-ON: "-faligned-allocation"
+
+// RUN: %clang_cl /c /std:c++17 -### /Zc:alignedNew- -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-OFF %s
+// ALIGNED-NEW-OFF-NOT: "-faligned-allocation"
+
// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=STRICTSTRINGS-DEFAULT %s
// STRICTSTRINGS-DEFAULT-NOT: -Werror=c++11-compat-deprecated-writable-strings
// RUN: %clang_cl /c -### /Zc:strictStrings -- %s 2>&1 | FileCheck -check-prefix=STRICTSTRINGS-ON %s