summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2023-11-02 17:27:34 +0100
committerStephan Bergmann <sbergman@redhat.com>2023-11-03 08:11:59 +0100
commitd614b08b7ff399bb9275691f811b01483ae03c5b (patch)
treed869c951d5b76f9654276ff3b37f9efc22c463ba
parent47e06b18ede70f3496bc7da97e1761fe1dbf629c (diff)
Suppress loplugin:redundantfcast also around C++20 CXXParenListInitExpr
...which is used by <https://github.com/llvm/llvm-project/commit/95a4c0c83554c025ef709a6805e67233d0dedba0> "[clang] Reland parenthesized aggregate init patches" for the __cpp_aggregate_paren_init feature implemented since Clang 16, and which had caused bogus warnings in patch set 1 of <https://gerrit.libreoffice.org/c/core/+/158838/1> "tdf#157028 vcl: PDF export: inline OBJR dictionaries" Change-Id: Id4118ce8d53902388ca3a80ad03f12b59e3a35e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158842 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--compilerplugins/clang/redundantfcast.cxx11
-rw-r--r--compilerplugins/clang/test/redundantfcast.cxx18
2 files changed, 27 insertions, 2 deletions
diff --git a/compilerplugins/clang/redundantfcast.cxx b/compilerplugins/clang/redundantfcast.cxx
index 5e74b22fe937..3a4dea0fd591 100644
--- a/compilerplugins/clang/redundantfcast.cxx
+++ b/compilerplugins/clang/redundantfcast.cxx
@@ -16,6 +16,8 @@
#include <unordered_set>
#include <vector>
+#include "config_clang.h"
+
namespace
{
class RedundantFCast final : public loplugin::FilteringPlugin<RedundantFCast>
@@ -288,10 +290,15 @@ public:
if (ignoreLocation(expr))
return true;
// specifying the name for an init-list is necessary sometimes
- if (isa<InitListExpr>(compat::IgnoreParenImplicit(expr->getSubExpr())))
+ auto const e = compat::IgnoreParenImplicit(expr->getSubExpr());
+ if (isa<InitListExpr>(e))
+ return true;
+ if (isa<CXXStdInitializerListExpr>(e))
return true;
- if (isa<CXXStdInitializerListExpr>(compat::IgnoreParenImplicit(expr->getSubExpr())))
+#if CLANG_VERSION >= 160000
+ if (isa<CXXParenListInitExpr>(e))
return true;
+#endif
auto const t1 = expr->getTypeAsWritten();
auto const t2 = compat::getSubExprAsWritten(expr)->getType();
if (!(t1.getCanonicalType().getTypePtr() == t2.getCanonicalType().getTypePtr()
diff --git a/compilerplugins/clang/test/redundantfcast.cxx b/compilerplugins/clang/test/redundantfcast.cxx
index a477e48f5308..1d13d8bea238 100644
--- a/compilerplugins/clang/test/redundantfcast.cxx
+++ b/compilerplugins/clang/test/redundantfcast.cxx
@@ -9,6 +9,7 @@
#include "sal/config.h"
+#include "config_clang.h"
#include "rtl/ustring.hxx"
#include "tools/color.hxx"
@@ -221,4 +222,21 @@ void foo()
(void)aGroup;
}
}
+
+namespace test9
+{
+struct S
+{
+ int n;
+};
+
+void f()
+{
+ (void)S{ 0 };
+#if CLANG_VERSION >= 160000
+ (void)S(0);
+#endif
+}
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */