summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/external.cxx8
-rw-r--r--compilerplugins/clang/test/external.cxx2
2 files changed, 8 insertions, 2 deletions
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