summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticGroups.td30
-rw-r--r--test/SemaCXX/cxx17-compat.cpp22
2 files changed, 44 insertions, 8 deletions
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td
index f22910dbae..3dc8c65f0f 100644
--- a/include/clang/Basic/DiagnosticGroups.td
+++ b/include/clang/Basic/DiagnosticGroups.td
@@ -184,13 +184,15 @@ def CXX98Compat : DiagGroup<"c++98-compat",
[CXX98CompatLocalTypeTemplateArgs,
CXX98CompatUnnamedTypeTemplateArgs,
CXXPre14Compat,
- CXXPre1zCompat]>;
+ CXXPre1zCompat,
+ CXXPre2aCompat]>;
// Warnings for C++11 features which are Extensions in C++98 mode.
def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
[CXX98Compat,
CXX98CompatBindToTemporaryCopy,
CXXPre14CompatPedantic,
- CXXPre1zCompatPedantic]>;
+ CXXPre1zCompatPedantic,
+ CXXPre2aCompatPedantic]>;
def CXX11Narrowing : DiagGroup<"c++11-narrowing">;
@@ -215,22 +217,34 @@ def CXX11Compat : DiagGroup<"c++11-compat",
CXX11CompatReservedUserDefinedLiteral,
CXX11CompatDeprecatedWritableStr,
CXXPre14Compat,
- CXXPre1zCompat]>;
+ CXXPre1zCompat,
+ CXXPre2aCompat]>;
def : DiagGroup<"c++0x-compat", [CXX11Compat]>;
def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic",
- [CXXPre14CompatPedantic,
- CXXPre1zCompatPedantic]>;
+ [CXX11Compat,
+ CXXPre14CompatPedantic,
+ CXXPre1zCompatPedantic,
+ CXXPre2aCompatPedantic]>;
-def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre1zCompat]>;
+def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre1zCompat,
+ CXXPre2aCompat]>;
def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic",
- [CXXPre1zCompatPedantic]>;
+ [CXX14Compat,
+ CXXPre1zCompatPedantic,
+ CXXPre2aCompatPedantic]>;
def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister,
DeprecatedIncrementBool,
- CXX17CompatMangling]>;
+ CXX17CompatMangling,
+ CXXPre2aCompat]>;
+def CXX17CompatPedantic : DiagGroup<"c++17-compat-pedantic",
+ [CXX17Compat,
+ CXXPre2aCompatPedantic]>;
def : DiagGroup<"c++1z-compat", [CXX17Compat]>;
def CXX2aCompat : DiagGroup<"c++2a-compat">;
+def CXX2aCompatPedantic : DiagGroup<"c++2a-compat-pedantic",
+ [CXX2aCompat]>;
def ExitTimeDestructors : DiagGroup<"exit-time-destructors">;
def FlexibleArrayExtensions : DiagGroup<"flexible-array-extensions">;
diff --git a/test/SemaCXX/cxx17-compat.cpp b/test/SemaCXX/cxx17-compat.cpp
new file mode 100644
index 0000000000..79c8507c9c
--- /dev/null
+++ b/test/SemaCXX/cxx17-compat.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++2a -Wc++17-compat-pedantic -verify %s
+
+struct A {};
+int (A::*pa)() const&;
+int use_pa = (A().*pa)();
+#if __cplusplus <= 201703L
+ // expected-warning@-2 {{invoking a pointer to a 'const &' member function on an rvalue is a C++2a extension}}
+#else
+ // expected-warning@-4 {{invoking a pointer to a 'const &' member function on an rvalue is incompatible with C++ standards before C++2a}}
+#endif
+
+struct B {
+ void b() {
+ (void) [=, this] {};
+#if __cplusplus <= 201703L
+ // expected-warning@-2 {{explicit capture of 'this' with a capture default of '=' is a C++2a extension}}
+#else
+ // expected-warning@-4 {{explicit capture of 'this' with a capture default of '=' is incompatible with C++ standards before C++2a}}
+#endif
+ }
+};