summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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: */