compilerplugins/clang/test/trivialconstructor.cxx |   10 ++++++++++
 compilerplugins/clang/trivialconstructor.cxx      |    2 ++
 2 files changed, 12 insertions(+)

New commits:
commit 10981fb2fa26474f432e85165b1babbca6d74e16
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Mar 16 15:23:52 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Wed Mar 16 21:10:27 2022 +0100

    Consistently avoid loplugin:trivialconstructor when there are defaulted 
params
    
    (The template default constructor in S8 had already been suppressed via
    
        std::distance(recordDecl->ctor_begin(), recordDecl->ctor_end()
    
    being zero, but the similar case in S7 caused a warning.)
    
    Change-Id: I4d18dec8bb971198eb8503262572a08c019c66bf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131663
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/compilerplugins/clang/test/trivialconstructor.cxx 
b/compilerplugins/clang/test/trivialconstructor.cxx
index ef17e9c60fee..5b48c4cf4250 100644
--- a/compilerplugins/clang/test/trivialconstructor.cxx
+++ b/compilerplugins/clang/test/trivialconstructor.cxx
@@ -43,4 +43,14 @@ template <typename> struct S6
     template <typename T> S6(T);
 };
 
+struct S7
+{
+    S7(int = 0) {}
+};
+
+struct S8
+{
+    template <typename T> S8(T = 0) {}
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/compilerplugins/clang/trivialconstructor.cxx 
b/compilerplugins/clang/trivialconstructor.cxx
index dd830058fac9..c991d71ae703 100644
--- a/compilerplugins/clang/trivialconstructor.cxx
+++ b/compilerplugins/clang/trivialconstructor.cxx
@@ -51,6 +51,8 @@ bool 
TrivialConstructor::VisitCXXConstructorDecl(CXXConstructorDecl const* const
         return true;
     if (!constructorDecl->isDefaultConstructor())
         return true;
+    if (constructorDecl->getNumParams() != 0)
+        return true;
     if (!constructorDecl->inits().empty())
         return true;
     if (constructorDecl->getExceptionSpecType() != EST_None)

Reply via email to