nuriamari created this revision. Herald added a project: All. nuriamari added reviewers: bruno, aaron.ballman. nuriamari added inline comments. nuriamari published this revision for review. Herald added a project: clang. Herald added a subscriber: cfe-commits.
================ Comment at: clang/test/CXX/basic/basic.def/p3.cpp:1 +// RUN: %clang_cc1 -std=c++17 -verify %s -Werror -Wdeprecated -Wno-error=deprecated-redundant-constexpr-static-def + ---------------- I'm not familiar with the naming convention of these test files. https://reviews.llvm.org/D126664 included a change in p2.cpp, and there is also a p4.cpp in the same directory, so I somewhat arbitrarily named this test p3.cpp. If these are meant to somehow correspond to the C++ standard or similar, please let me know. In https://reviews.llvm.org/D126664, a warning is introduced warning against the deprecated out of line definition of a static constexpr member in C++17 and later. Prior to this patch, the only diagnostic group controlling this diagnostic was -Wdeprecated, which controls many many diagnostics. This patch creates a diagnostic group specifically for this warning so it can be controlled in isolation, while also being included with -Wdeprecated. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D153881 Files: clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/test/CXX/basic/basic.def/p3.cpp Index: clang/test/CXX/basic/basic.def/p3.cpp =================================================================== --- /dev/null +++ clang/test/CXX/basic/basic.def/p3.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -std=c++17 -verify %s -Werror -Wdeprecated -Wno-error=deprecated-redundant-constexpr-static-def + +namespace { + struct A { + static constexpr int n = 0; + }; + const int A::n; // expected-warning{{out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated}} +} Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -450,7 +450,7 @@ def warn_deprecated_redundant_constexpr_static_def : Warning< "out-of-line definition of constexpr static data member is redundant " "in C++17 and is deprecated">, - InGroup<Deprecated>, DefaultIgnore; + InGroup<DeprecatedRedundantConstexprStaticDef>, DefaultIgnore; def warn_decl_shadow : Warning<"declaration shadows a %select{" Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -186,6 +186,7 @@ // For compatibility with GCC. def : DiagGroup<"deprecated-copy-dtor", [DeprecatedCopyWithDtor]>; def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">; +def DeprecatedRedundantConstexprStaticDef : DiagGroup<"deprecated-redundant-constexpr-static-def">; def UnavailableDeclarations : DiagGroup<"unavailable-declarations">; def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">; def UnguardedAvailability : DiagGroup<"unguarded-availability", @@ -224,7 +225,9 @@ DeprecatedThisCapture, DeprecatedType, DeprecatedVolatile, - DeprecatedWritableStr]>, + DeprecatedWritableStr, + DeprecatedRedundantConstexprStaticDef, + ]>, DiagCategory<"Deprecations">; def CXX20Designator : DiagGroup<"c++20-designator">;
Index: clang/test/CXX/basic/basic.def/p3.cpp =================================================================== --- /dev/null +++ clang/test/CXX/basic/basic.def/p3.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -std=c++17 -verify %s -Werror -Wdeprecated -Wno-error=deprecated-redundant-constexpr-static-def + +namespace { + struct A { + static constexpr int n = 0; + }; + const int A::n; // expected-warning{{out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated}} +} Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -450,7 +450,7 @@ def warn_deprecated_redundant_constexpr_static_def : Warning< "out-of-line definition of constexpr static data member is redundant " "in C++17 and is deprecated">, - InGroup<Deprecated>, DefaultIgnore; + InGroup<DeprecatedRedundantConstexprStaticDef>, DefaultIgnore; def warn_decl_shadow : Warning<"declaration shadows a %select{" Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -186,6 +186,7 @@ // For compatibility with GCC. def : DiagGroup<"deprecated-copy-dtor", [DeprecatedCopyWithDtor]>; def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">; +def DeprecatedRedundantConstexprStaticDef : DiagGroup<"deprecated-redundant-constexpr-static-def">; def UnavailableDeclarations : DiagGroup<"unavailable-declarations">; def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">; def UnguardedAvailability : DiagGroup<"unguarded-availability", @@ -224,7 +225,9 @@ DeprecatedThisCapture, DeprecatedType, DeprecatedVolatile, - DeprecatedWritableStr]>, + DeprecatedWritableStr, + DeprecatedRedundantConstexprStaticDef, + ]>, DiagCategory<"Deprecations">; def CXX20Designator : DiagGroup<"c++20-designator">;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits