compilerplugins/clang/redundantfcast.cxx      |   11 +++++++++--
 compilerplugins/clang/test/redundantfcast.cxx |   18 ++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit d614b08b7ff399bb9275691f811b01483ae03c5b
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Thu Nov 2 17:27:34 2023 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Fri Nov 3 08:11:59 2023 +0100

    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 <sberg...@redhat.com>

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: */

Reply via email to