From 1c233c55171af9101962ba9a5c2bda7ace18fcfe Mon Sep 17 00:00:00 2001 From: Adam Gajda <80600850+adgajda@users.noreply.github.com> Date: Wed, 13 Mar 2024 13:19:59 -0700 Subject: PR #1603: Disable -Wnon-virtual-dtor warning for CommandLineFlag implementations Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1603 Merge e324303b1f2aaee8e4418cffb838f150a2d4f4e7 into d802708117c6ef6b9783efe499b2a2d0d0536c77 Merging this change closes #1603 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1603 from adgajda:master e324303b1f2aaee8e4418cffb838f150a2d4f4e7 PiperOrigin-RevId: 615522811 Change-Id: I46a388ac62ffd42ce175dbfa04e414dd498855f8 --- absl/flags/reflection.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'absl/flags/reflection.cc') diff --git a/absl/flags/reflection.cc b/absl/flags/reflection.cc index 841921a9..ea856ff9 100644 --- a/absl/flags/reflection.cc +++ b/absl/flags/reflection.cc @@ -217,6 +217,13 @@ void FinalizeRegistry() { namespace { +// These are only used as constexpr global objects. +// They do not use a virtual destructor to simplify their implementation. +// They are not destroyed except at program exit, so leaks do not matter. +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#endif class RetiredFlagObj final : public CommandLineFlag { public: constexpr RetiredFlagObj(const char* name, FlagFastTypeId type_id) @@ -276,6 +283,9 @@ class RetiredFlagObj final : public CommandLineFlag { const char* const name_; const FlagFastTypeId type_id_; }; +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif } // namespace -- cgit v1.2.3