From 07bcbcf39e1a8dc2b4098a8480d0310cc67d78ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 6 Sep 2024 21:18:21 +0000 Subject: [PATCH] Disable clang warning for injected class name ambiguity in non_copyable_reference MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit clang raises a warning (-Winjected-class-name) due to ambiguity between a constructor name and a type within the non_copyable_reference code. Since clang could not infer the correct type context, this commit uses `#pragma clang diagnostic` to disable the specific warning in the affected area of the code. The `push` and `pop` pragmas ensure that the warning is disabled only where needed, preventing it from affecting other parts of the codebase, and allowing us to maintain clean and clear code without unnecessary compiler warnings. A static_assert enforces that CustomDeleter::deleter is indeed a type, although interpreting it as a constructor would be non-sensical here. Change-Id: Ic0aac06d7af4272438f6f3d0275f29dc57a32194 Signed-off-by: Jérémie Galarneau --- src/common/reference.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/reference.hpp b/src/common/reference.hpp index 7b1d0b8c1..15dac55b9 100644 --- a/src/common/reference.hpp +++ b/src/common/reference.hpp @@ -76,7 +76,13 @@ private: return; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Winjected-class-name" + static_assert(std::is_class::value, + "CustomDeleter must define a 'deleter' callable class."); const typename CustomDeleter::deleter del; +#pragma clang diagnostic pop + del(_value); release(); } -- 2.34.1