compilerplugins/clang/external.cxx      |    8 ++++++--
 compilerplugins/clang/test/external.cxx |    2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

New commits:
commit ef57b9cd3c4c37fe70b7bc89361393f6f8b36d07
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Fri Nov 15 12:59:31 2019 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Fri Nov 15 17:55:00 2019 +0100

    loplugin:external: Note all other declarations of the same entity
    
    ...not just those that came before
    
    Change-Id: Ib10ca34cb2ee63124999d56bb00d94f000f33ea1
    Reviewed-on: https://gerrit.libreoffice.org/82782
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/compilerplugins/clang/external.cxx 
b/compilerplugins/clang/external.cxx
index fe4328c1187b..442d174bd15b 100644
--- a/compilerplugins/clang/external.cxx
+++ b/compilerplugins/clang/external.cxx
@@ -295,9 +295,13 @@ private:
             decl->getLocation())
             << (typedefed != nullptr) << (typedefed == nullptr ? decl : 
typedefed) << canStatic
             << (canStatic && canUnnamed) << canUnnamed << 
decl->getSourceRange();
-        for (auto d = decl->getPreviousDecl(); d != nullptr; d = 
d->getPreviousDecl())
+        for (auto d = decl->redecls_begin(); d != decl->redecls_end(); ++d)
         {
-            report(DiagnosticsEngine::Note, "previous declaration is here", 
d->getLocation())
+            if (*d == decl)
+            {
+                continue;
+            }
+            report(DiagnosticsEngine::Note, "another declaration is here", 
d->getLocation())
                 << d->getSourceRange();
         }
         //TODO: Class template specializations can be in the enclosing 
namespace, so no need to
diff --git a/compilerplugins/clang/test/external.cxx 
b/compilerplugins/clang/test/external.cxx
index f4f3d770f09d..fd7d558efc09 100644
--- a/compilerplugins/clang/test/external.cxx
+++ b/compilerplugins/clang/test/external.cxx
@@ -9,6 +9,8 @@
 
 // expected-error@+1 {{externally available entity 'n1' is not previously 
declared in an included file (if it is only used in this translation unit, make 
it static or put it in an unnamed namespace; otherwise, provide a declaration 
of it in an included file) [loplugin:external]}}
 int n1 = 0;
+// expected-note@+1 {{another declaration is here [loplugin:external]}}
+extern int n1;
 
 int const n2 = 0; // no warning, internal linkage
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to