Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -1040,6 +1040,13 @@ def NonGCC : DiagGroup<"non-gcc", [SignCompare, Conversion, LiteralRange]>; +def CXX14Attrs : DiagGroup<"c++14-attribute-extensions">; +def CXX17Attrs : DiagGroup<"c++17-attribute-extensions">; +def CXX20Attrs : DiagGroup<"c++20-attribute-extensions">; +def FutureAttrs : DiagGroup<"future-attribute-extensions", [CXX14Attrs, + CXX17Attrs, + CXX20Attrs]>; + // A warning group for warnings about using C++11 features as extensions in // earlier C++ versions. def CXX11 : DiagGroup<"c++11-extensions", [CXX11ExtraSemi, CXX11InlineNamespace, @@ -1047,15 +1054,15 @@ // A warning group for warnings about using C++14 features as extensions in // earlier C++ versions. -def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral]>; +def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral, CXX14Attrs]>; // A warning group for warnings about using C++17 features as extensions in // earlier C++ versions. -def CXX17 : DiagGroup<"c++17-extensions">; +def CXX17 : DiagGroup<"c++17-extensions", [CXX17Attrs]>; // A warning group for warnings about using C++20 features as extensions in // earlier C++ versions. -def CXX20 : DiagGroup<"c++20-extensions", [CXX20Designator]>; +def CXX20 : DiagGroup<"c++20-extensions", [CXX20Designator, CXX20Attrs]>; // A warning group for warnings about using C++2b features as extensions in // earlier C++ versions. Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8617,11 +8617,11 @@ InGroup>; def ext_cxx14_attr : Extension< - "use of the %0 attribute is a C++14 extension">, InGroup; + "use of the %0 attribute is a C++14 extension">, InGroup; def ext_cxx17_attr : Extension< - "use of the %0 attribute is a C++17 extension">, InGroup; + "use of the %0 attribute is a C++17 extension">, InGroup; def ext_cxx20_attr : Extension< - "use of the %0 attribute is a C++20 extension">, InGroup; + "use of the %0 attribute is a C++20 extension">, InGroup; def warn_unused_comparison : Warning< "%select{equality|inequality|relational|three-way}0 comparison result unused">, Index: clang/test/SemaCXX/attr-extension-diags.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/attr-extension-diags.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -std=c++11 -verify=ext -fsyntax-only -Wfuture-attribute-extensions %s +// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-future-attribute-extensions %s +// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++14-attribute-extensions -Wno-c++17-attribute-extensions -Wno-c++20-attribute-extensions %s + +// expected-no-diagnostics + +[[deprecated]] int func1(); // ext-warning {{use of the 'deprecated' attribute is a C++14 extension}} +[[deprecated("msg")]] int func2(); // ext-warning {{use of the 'deprecated' attribute is a C++14 extension}} + +[[nodiscard]] int func3(); // ext-warning {{use of the 'nodiscard' attribute is a C++17 extension}} +[[nodiscard("msg")]] int func4(); // ext-warning {{use of the 'nodiscard' attribute is a C++20 extension}} + +void func5() { + if (true) [[likely]]; // ext-warning {{use of the 'likely' attribute is a C++20 extension}} +}