nuriamari updated this revision to Diff 538751. nuriamari added a comment. - Create entry in release notes - Move test to appropriate location - Expand test to include `const` warning controlled in the same warning group
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153881/new/ https://reviews.llvm.org/D153881 Files: clang/docs/ReleaseNotes.rst clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp Index: clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp @@ -0,0 +1,10 @@ +// 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; + static constexpr int m = 0; + }; + constexpr int A::n; // expected-warning{{out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated}} + const int A::m; // 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/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -370,6 +370,10 @@ - Clang now diagnoses unexpected tokens after a ``#pragma clang|GCC diagnostic push|pop`` directive. (`#13920: <https://github.com/llvm/llvm-project/issues/13920>`_) +- A new diagnostic warning group ``deprecated-redundant-constexpr-static-def`` is + added. This is to be used to control warnings about out-of-line definitions of + static constexpr members that are unnecessary with ``-std=C++17`` onwards. The + diagnostic was previously only controllable via `-Wdeprecated`. Bug Fixes in This Version -------------------------
Index: clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/redundant-out-of-line-static-constexpr-member-def-diag.cpp @@ -0,0 +1,10 @@ +// 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; + static constexpr int m = 0; + }; + constexpr int A::n; // expected-warning{{out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated}} + const int A::m; // 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/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -370,6 +370,10 @@ - Clang now diagnoses unexpected tokens after a ``#pragma clang|GCC diagnostic push|pop`` directive. (`#13920: <https://github.com/llvm/llvm-project/issues/13920>`_) +- A new diagnostic warning group ``deprecated-redundant-constexpr-static-def`` is + added. This is to be used to control warnings about out-of-line definitions of + static constexpr members that are unnecessary with ``-std=C++17`` onwards. The + diagnostic was previously only controllable via `-Wdeprecated`. Bug Fixes in This Version -------------------------
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits