[Libreoffice-commits] core.git: 40 commits - canvas/source compilerplugins/clang connectivity/source dbaccess/source desktop/source desktop/unx editeng/source extensions/source filter/source framework/source hwpfilter/source i18npool/source i18nutil/source idlc/source idl/source include/i18nutil include/rtl jvmfwk/plugins jvmfwk/source l10ntools/source libreofficekit/source linguistic/source odk/source pyuno/source rsc/source sal/inc sal/osl sal/qa sc/inc scripting/source sc/source sdext/source sd/source sfx2/source shell/source solenv/CompilerTest_compilerplugins_clang.mk svl/source svtools/source svx/source sw/inc sw/qa sw/source ucb/source unotools/inc unotools/Library_utl.mk unotools/source vbahelper/source vcl/inc vcl/opengl vcl/source vcl/unx vcl/workben writerfilter/source xmlhelp/source xmloff/inc xmloff/source xmlscript/source xmlsecurity/source

Stephan Bergmann sbergman at redhat.com
Mon Jan 9 14:45:34 UTC 2017


 canvas/source/cairo/cairo_services.cxx                                |    4 
 canvas/source/opengl/ogl_spritecanvas.cxx                             |    2 
 canvas/source/vcl/services.cxx                                        |    4 
 compilerplugins/clang/externvar.cxx                                   |  104 +++++
 compilerplugins/clang/test/externvar.cxx                              |   61 +++
 compilerplugins/clang/test/externvar.hxx                              |   27 +
 connectivity/source/drivers/mork/MorkParser.cxx                       |   11 
 connectivity/source/drivers/mork/MorkParser.hxx                       |    4 
 connectivity/source/drivers/odbc/ORealDriver.cxx                      |   64 ---
 connectivity/source/inc/odbc/OFunctions.hxx                           |   63 +++
 connectivity/source/parse/sqlbison.y                                  |    2 
 connectivity/source/parse/sqlnode.cxx                                 |    2 
 dbaccess/source/core/misc/services.cxx                                |    2 
 dbaccess/source/ui/querydesign/LimitBox.cxx                           |    2 
 desktop/source/deployment/dp_log.cxx                                  |    5 
 desktop/source/deployment/dp_services.cxx                             |   47 --
 desktop/source/deployment/gui/dp_gui_service.cxx                      |    6 
 desktop/source/deployment/inc/dp_services.hxx                         |   65 +++
 desktop/source/deployment/manager/dp_extensionmanager.cxx             |    5 
 desktop/source/deployment/manager/dp_informationprovider.cxx          |    5 
 desktop/source/deployment/manager/dp_managerfac.cxx                   |    5 
 desktop/source/deployment/registry/component/dp_component.cxx         |    3 
 desktop/source/deployment/registry/configuration/dp_configuration.cxx |    3 
 desktop/source/deployment/registry/executable/dp_executable.cxx       |    3 
 desktop/source/deployment/registry/help/dp_help.cxx                   |    3 
 desktop/source/deployment/registry/script/dp_script.cxx               |    3 
 desktop/source/deployment/registry/sfwk/dp_sfwk.cxx                   |    7 
 desktop/source/migration/services/cexports.cxx                        |    2 
 desktop/source/migration/services/cexportsoo3.cxx                     |    2 
 desktop/unx/source/start.c                                            |    2 
 editeng/source/accessibility/AccessibleStaticTextBase.cxx             |    2 
 extensions/source/bibliography/bibmod.cxx                             |    1 
 extensions/source/bibliography/datman.cxx                             |   10 
 extensions/source/resource/resourceservices.cxx                       |    4 
 filter/source/flash/swfexporter.cxx                                   |    2 
 filter/source/graphic/Services.cxx                                    |    4 
 filter/source/msfilter/msocximex.cxx                                  |    2 
 filter/source/msfilter/msvbahelper.cxx                                |    4 
 filter/source/svg/svgfilter.cxx                                       |    4 
 filter/source/t602/t602filter.cxx                                     |   10 
 framework/source/fwe/xml/menudocumenthandler.cxx                      |    2 
 framework/source/fwe/xml/statusbardocumenthandler.cxx                 |    2 
 framework/source/fwe/xml/toolboxdocumenthandler.cxx                   |    4 
 framework/source/xml/imagesdocumenthandler.cxx                        |    2 
 hwpfilter/source/fontmap.cxx                                          |    2 
 hwpfilter/source/formula.cxx                                          |    3 
 hwpfilter/source/grammar.cxx                                          |   16 
 hwpfilter/source/lexer.cxx                                            |   10 
 hwpfilter/source/nodes.h                                              |    5 
 i18npool/source/collator/chaptercollator.cxx                          |    6 
 i18npool/source/inputchecker/inputsequencechecker_hi.cxx              |    2 
 i18npool/source/inputchecker/inputsequencechecker_th.cxx              |    4 
 i18npool/source/nativenumber/nativenumbersupplier.cxx                 |    4 
 i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx     |    2 
 i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx         |    2 
 i18npool/source/transliteration/ignoreSeparator_ja_JP.cxx             |    2 
 i18npool/source/transliteration/ignoreSpace_ja_JP.cxx                 |    2 
 i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP.cxx      |    2 
 i18npool/source/transliteration/largeToSmall_ja_JP.cxx                |    2 
 i18npool/source/transliteration/smallToLarge_ja_JP.cxx                |    2 
 i18nutil/source/utility/oneToOneMapping.cxx                           |    2 
 idl/source/prj/command.cxx                                            |    4 
 idlc/source/idlccompile.cxx                                           |    3 
 idlc/source/idlcproduce.cxx                                           |    2 
 include/i18nutil/oneToOneMapping.hxx                                  |    4 
 include/rtl/strbuf.hxx                                                |    5 
 include/rtl/string.hxx                                                |    5 
 include/rtl/stringconcat.hxx                                          |    4 
 include/rtl/ustrbuf.hxx                                               |    4 
 include/rtl/ustring.hxx                                               |    4 
 jvmfwk/plugins/sunmajor/pluginlib/util.cxx                            |    2 
 jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx                      |    2 
 jvmfwk/source/fwkbase.cxx                                             |    2 
 l10ntools/source/uimerge.cxx                                          |    4 
 l10ntools/source/xrmmerge.cxx                                         |   20 -
 libreofficekit/source/gtk/lokdocview.cxx                              |    2 
 linguistic/source/lngopt.cxx                                          |    2 
 odk/source/unoapploader/unx/unoapploader.c                            |    4 
 pyuno/source/module/pyuno_gc.cxx                                      |    4 
 rsc/source/parser/rsclex.cxx                                          |    9 
 rsc/source/parser/rscyacc.y                                           |    4 
 sal/inc/salusesyslog.hxx                                              |   23 +
 sal/osl/all/log.cxx                                                   |    1 
 sal/osl/unx/salinit.cxx                                               |    3 
 sal/qa/osl/file/osl_File.cxx                                          |    2 
 sal/qa/rtl/strings/test_ostring_concat.cxx                            |    3 
 sal/qa/rtl/strings/test_ostring_stringliterals.cxx                    |    8 
 sal/qa/rtl/strings/test_oustring_stringliterals.cxx                   |    7 
 sc/inc/drwlayer.hxx                                                   |    2 
 sc/inc/global.hxx                                                     |    5 
 sc/source/core/data/column3.cxx                                       |    2 
 sc/source/core/data/documen7.cxx                                      |    2 
 sc/source/core/data/table4.cxx                                        |    2 
 sc/source/core/tool/autoform.cxx                                      |    2 
 sc/source/core/tool/cellform.cxx                                      |    3 
 sc/source/filter/xml/editattributemap.cxx                             |    2 
 sc/source/ui/inc/drawview.hxx                                         |    2 
 sc/source/ui/inc/viewfunc.hxx                                         |    3 
 sc/source/ui/undo/undotab.cxx                                         |    2 
 sc/source/ui/unoobj/targuno.cxx                                       |    2 
 sc/source/ui/vba/service.cxx                                          |   28 -
 sc/source/ui/vba/service.hxx                                          |   43 ++
 sc/source/ui/vba/vbaapplication.cxx                                   |    5 
 sc/source/ui/vba/vbahyperlink.cxx                                     |    7 
 sc/source/ui/vba/vbarange.cxx                                         |    5 
 sc/source/ui/vba/vbawindow.cxx                                        |    5 
 sc/source/ui/vba/vbaworkbook.cxx                                      |    5 
 sc/source/ui/vba/vbaworksheet.cxx                                     |    5 
 sc/source/ui/view/gridwin.cxx                                         |    7 
 sc/source/ui/view/select.cxx                                          |    2 
 sc/source/ui/view/tabview4.cxx                                        |    2 
 sc/source/ui/view/tabvwsh4.cxx                                        |    2 
 sc/source/ui/view/viewfun7.cxx                                        |    2 
 scripting/source/vbaevents/eventhelper.cxx                            |   60 +--
 sd/source/core/EffectMigration.cxx                                    |   12 
 sd/source/filter/eppt/pptx-text.cxx                                   |    2 
 sd/source/filter/html/htmlex.cxx                                      |    2 
 sd/source/filter/html/pubdlg.cxx                                      |    2 
 sd/source/ui/dlg/headerfooterdlg.cxx                                  |    2 
 sd/source/ui/sidebar/PanelFactory.cxx                                 |    2 
 sdext/source/pdfimport/test/pdfunzip.cxx                              |    2 
 sfx2/source/appl/appuno.cxx                                           |    2 
 sfx2/source/appl/shutdowniconunx.cxx                                  |    2 
 sfx2/source/control/unoctitm.cxx                                      |    2 
 sfx2/source/dialog/backingwindow.cxx                                  |    2 
 sfx2/source/doc/doctempl.cxx                                          |    2 
 sfx2/source/view/sfxbasecontroller.cxx                                |    2 
 shell/source/sessioninstall/services.cxx                              |    2 
 solenv/CompilerTest_compilerplugins_clang.mk                          |    1 
 svl/source/items/poolitem.cxx                                         |   10 
 svl/source/items/style.cxx                                            |    4 
 svtools/source/brwbox/brwbox2.cxx                                     |    4 
 svtools/source/config/colorcfg.cxx                                    |    2 
 svtools/source/config/extcolorcfg.cxx                                 |    2 
 svtools/source/misc/unitconv.cxx                                      |    2 
 svx/source/form/fmshell.cxx                                           |    2 
 svx/source/form/fmundo.cxx                                            |    2 
 svx/source/tbxctrls/extrusioncontrols.cxx                             |    4 
 sw/inc/init.hxx                                                       |    9 
 sw/inc/swmodule.hxx                                                   |    2 
 sw/inc/view.hxx                                                       |    2 
 sw/qa/core/Test-BigPtrArray.cxx                                       |    6 
 sw/qa/extras/mailmerge/mailmerge.cxx                                  |    2 
 sw/source/core/bastyp/init.cxx                                        |    4 
 sw/source/core/doc/doccomp.cxx                                        |    3 
 sw/source/core/doc/docdesc.cxx                                        |    7 
 sw/source/core/fields/authfld.cxx                                     |    2 
 sw/source/core/frmedt/feshview.cxx                                    |    2 
 sw/source/core/frmedt/fetab.cxx                                       |    5 
 sw/source/core/inc/fetab.hxx                                          |   28 +
 sw/source/core/inc/frmtool.hxx                                        |    2 
 sw/source/core/inc/paintfrm.hxx                                       |    2 
 sw/source/core/layout/hffrm.cxx                                       |    2 
 sw/source/core/layout/tabfrm.cxx                                      |    8 
 sw/source/core/ole/ndole.cxx                                          |    2 
 sw/source/core/text/inftxt.cxx                                        |    3 
 sw/source/core/txtnode/fntcache.cxx                                   |    3 
 sw/source/core/undo/untbl.cxx                                         |    4 
 sw/source/core/view/viewsh.cxx                                        |    2 
 sw/source/filter/basflt/fltini.cxx                                    |    2 
 sw/source/filter/html/css1atr.cxx                                     |  190 ++++------
 sw/source/filter/html/htmlatr.cxx                                     |    3 
 sw/source/filter/html/htmlatr.hxx                                     |   21 +
 sw/source/filter/html/htmlflywriter.cxx                               |    3 
 sw/source/filter/ww8/docxexportfilter.cxx                             |    2 
 sw/source/filter/xml/xmlexpit.cxx                                     |    4 
 sw/source/filter/xml/xmlimpit.cxx                                     |    2 
 sw/source/filter/xml/xmlitem.cxx                                      |    2 
 sw/source/filter/xml/xmliteme.cxx                                     |    4 
 sw/source/filter/xml/xmlitemi.cxx                                     |    5 
 sw/source/filter/xml/xmlitemm.cxx                                     |    8 
 sw/source/filter/xml/xmlitmap.hxx                                     |   11 
 sw/source/filter/xml/xmlitmpr.cxx                                     |   10 
 sw/source/ui/dialog/swdialmgr.cxx                                     |    1 
 sw/source/ui/vba/service.cxx                                          |   27 -
 sw/source/ui/vba/service.hxx                                          |   35 +
 sw/source/ui/vba/vbadocument.cxx                                      |   22 -
 sw/source/ui/vba/vbaeventshelper.cxx                                  |    7 
 sw/source/ui/vba/vbaglobals.cxx                                       |    5 
 sw/source/ui/vba/vbawrapformat.cxx                                    |    8 
 sw/source/uibase/app/docst.cxx                                        |    2 
 sw/source/uibase/chrdlg/ccoll.cxx                                     |    2 
 sw/source/uibase/dbui/mmconfigitem.cxx                                |   36 -
 sw/source/uibase/dochdl/swdtflvr.cxx                                  |    5 
 sw/source/uibase/docvw/edtdd.cxx                                      |    5 
 sw/source/uibase/docvw/edtwin.cxx                                     |   10 
 sw/source/uibase/inc/edtdd.hxx                                        |   19 +
 sw/source/uibase/inc/edtwin.hxx                                       |    5 
 sw/source/uibase/ribbar/conform.cxx                                   |    3 
 sw/source/uibase/ribbar/drawbase.cxx                                  |    3 
 sw/source/uibase/shells/textfld.cxx                                   |    2 
 sw/source/uibase/uiview/view.cxx                                      |    2 
 sw/source/uibase/uiview/view1.cxx                                     |    6 
 sw/source/uibase/uiview/viewport.cxx                                  |    3 
 sw/source/uibase/utlui/initui.cxx                                     |    4 
 sw/source/uibase/wrtsh/wrtsh3.cxx                                     |    3 
 ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx                        |    3 
 ucb/source/ucp/webdav-neon/NeonPropFindRequest.cxx                    |    3 
 ucb/source/ucp/webdav-neon/NeonSession.hxx                            |    2 
 unotools/Library_utl.mk                                               |    5 
 unotools/inc/unotoolsservices.hxx                                     |   22 +
 unotools/source/config/misccfg.cxx                                    |    2 
 unotools/source/config/printwarningoptions.cxx                        |    2 
 unotools/source/misc/ServiceDocumenter.cxx                            |    5 
 unotools/source/misc/fontcvt.cxx                                      |   12 
 unotools/source/misc/unotoolsservices.cxx                             |    6 
 unotools/source/ucbhelper/xtempfile.cxx                               |    5 
 vbahelper/source/msforms/service.cxx                                  |   12 
 vbahelper/source/msforms/service.hxx                                  |   27 +
 vbahelper/source/msforms/vbacontrol.cxx                               |    9 
 vbahelper/source/msforms/vbauserform.cxx                              |    5 
 vcl/inc/svdata.hxx                                                    |    2 
 vcl/opengl/x11/gdiimpl.cxx                                            |    2 
 vcl/source/app/svapp.cxx                                              |    2 
 vcl/source/filter/sgvmain.hxx                                         |    2 
 vcl/source/filter/sgvtext.cxx                                         |    2 
 vcl/unx/generic/app/i18n_keysym.cxx                                   |    2 
 vcl/unx/gtk/a11y/atktextattributes.cxx                                |   10 
 vcl/unx/gtk/gtkdata.cxx                                               |    2 
 vcl/unx/gtk3/gtk3gtkdata.cxx                                          |    2 
 vcl/workben/fftester.cxx                                              |    2 
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx                 |    2 
 xmlhelp/source/cxxhelp/provider/urlparameter.cxx                      |    2 
 xmloff/inc/enummaps.hxx                                               |   23 +
 xmloff/source/draw/XMLNumberStyles.cxx                                |   12 
 xmloff/source/draw/sdpropls.cxx                                       |    7 
 xmloff/source/draw/shapeexport.cxx                                    |    4 
 xmloff/source/draw/ximpshap.cxx                                       |    4 
 xmloff/source/draw/ximpshap.hxx                                       |    5 
 xmloff/source/style/PageMasterPropHdlFactory.cxx                      |    6 
 xmloff/source/style/XMLFontStylesContext.cxx                          |   12 
 xmloff/source/style/backhdl.cxx                                       |    4 
 xmloff/source/style/bordrhdl.cxx                                      |    4 
 xmloff/source/style/breakhdl.cxx                                      |    2 
 xmloff/source/style/cdouthdl.cxx                                      |    6 
 xmloff/source/style/xmltabe.cxx                                       |    2 
 xmloff/source/text/XMLIndexTemplateContext.cxx                        |    2 
 xmloff/source/text/txtprhdl.cxx                                       |    6 
 xmloff/source/text/txtprmap.cxx                                       |   24 -
 xmloff/source/transform/MetaTContext.cxx                              |    4 
 xmloff/source/xforms/xformsexport.cxx                                 |   10 
 xmlscript/source/xmldlg_imexp/common.hxx                              |    9 
 xmlscript/source/xmldlg_imexp/xmldlg_export.cxx                       |    8 
 xmlscript/source/xmldlg_imexp/xmldlg_import.cxx                       |    8 
 xmlsecurity/source/xmlsec/xmlstreamio.cxx                             |    2 
 245 files changed, 1178 insertions(+), 774 deletions(-)

New commits:
commit ce38f88151817648ae2fdb9788f5a40d12b1057a
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:44:47 2017 +0100

    New loplugin:externvar
    
    Change-Id: Ie5404f11cbc5b05bd18455ae81526eb2de01548c

diff --git a/compilerplugins/clang/externvar.cxx b/compilerplugins/clang/externvar.cxx
new file mode 100644
index 0000000..9569a3d
--- /dev/null
+++ b/compilerplugins/clang/externvar.cxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "check.hxx"
+#include "plugin.hxx"
+
+// Find variable declarations at namespace scope that need not have external
+// linkage.
+
+namespace {
+
+// It looks like Clang wrongly implements DR 4
+// (<http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#4>) and treats
+// a variable declared in an 'extern "..." {...}'-style linkage-specification as
+// if it contained the 'extern' specifier:
+bool hasExternalLinkage(VarDecl const * decl) {
+    if (decl->getLinkageAndVisibility().getLinkage() != ExternalLinkage) {
+        return false;
+    }
+    for (auto ctx = decl->getLexicalDeclContext();
+         ctx->getDeclKind() != Decl::TranslationUnit;
+         ctx = ctx->getLexicalParent())
+    {
+        if (auto ls = dyn_cast<LinkageSpecDecl>(ctx)) {
+            if (!ls->hasBraces()) {
+                return true;
+            }
+            if (auto prev = decl->getPreviousDecl()) {
+                return hasExternalLinkage(prev);
+            }
+            return !decl->isInAnonymousNamespace();
+        }
+    }
+    return true;
+}
+
+class ExternVar: public RecursiveASTVisitor<ExternVar>, public loplugin::Plugin
+{
+public:
+    explicit ExternVar(InstantiationData const & data): Plugin(data) {}
+
+    void run() override
+    { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
+
+    bool VisitVarDecl(VarDecl const * decl) {
+        if (ignoreLocation(decl)) {
+            return true;
+        }
+        if (decl->isStaticDataMember()) {
+            return true;
+        }
+        if (!(decl->isFirstDecl()
+              && compiler.getSourceManager().isInMainFile(decl->getLocation())
+              && hasExternalLinkage(decl)))
+        {
+            return true;
+        }
+        auto def = decl->getDefinition();
+        if (def == nullptr) {
+            // Code like
+            //
+            //   namespace { extern int v; }
+            //   int f() { return sizeof(v); }
+            //
+            // is already handled by Clang itself with an error "variable 'v' is
+            // not needed and will not be emitted"
+            return true;
+        }
+        report(
+            DiagnosticsEngine::Warning,
+            "variable with external linkage not declared in an include file",
+            def->getLocation())
+            << def->getSourceRange();
+        report(
+            DiagnosticsEngine::Note,
+            ("should either have internal linkage or be declared in an include"
+             " file"),
+            def->getLocation())
+            << def->getSourceRange();
+        for (auto prev = def;;) {
+            prev = prev->getPreviousDecl();
+            if (prev == nullptr) {
+                break;
+            }
+            report(
+                DiagnosticsEngine::Note, "previously declared here",
+                prev->getLocation())
+                << prev->getSourceRange();
+        }
+        return true;
+    }
+};
+
+loplugin::Plugin::Registration<ExternVar> X("externvar");
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/test/externvar.cxx b/compilerplugins/clang/test/externvar.cxx
new file mode 100644
index 0000000..51f743f
--- /dev/null
+++ b/compilerplugins/clang/test/externvar.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <externvar.hxx>
+
+int v1;
+int v2; // expected-error {{variable with external linkage not declared in an include file [loplugin:externvar]}} expected-note {{should either have internal linkage or be declared in an include file [loplugin:externvar]}}
+static int v3;
+int const v4 = 0;
+
+extern int v5; // expected-note {{previously declared here [loplugin:externvar]}}
+int v5; // expected-error {{variable with external linkage not declared in an include file [loplugin:externvar]}} expected-note {{should either have internal linkage or be declared in an include file [loplugin:externvar]}}
+
+extern "C" int v6; // expected-note {{previously declared here [loplugin:externvar]}}
+int v6; // expected-error {{variable with external linkage not declared in an include file [loplugin:externvar]}} expected-note {{should either have internal linkage or be declared in an include file [loplugin:externvar]}}
+extern "C" { int v7; } // expected-error {{variable with external linkage not declared in an include file [loplugin:externvar]}} expected-note {{should either have internal linkage or be declared in an include file [loplugin:externvar]}}
+
+namespace {
+
+int u1;
+static int u2;
+extern "C" int u3; // expected-note {{previously declared here [loplugin:externvar]}}
+int u3; // expected-error {{variable with external linkage not declared in an include file [loplugin:externvar]}} expected-note {{should either have internal linkage or be declared in an include file [loplugin:externvar]}}
+extern "C" { int u4; }
+
+}
+
+namespace N {
+
+int v1;
+int v2; // expected-error {{variable with external linkage not declared in an include file [loplugin:externvar]}} expected-note {{should either have internal linkage or be declared in an include file [loplugin:externvar]}}
+static int v3;
+
+}
+
+struct S {
+    static int f() {
+        static int s = 0;
+        return s;
+    }
+
+    static int m;
+};
+
+int S::m = 0;
+
+int f(int a) {
+    static int s = 0;
+    ++s;
+    int b = a + s + v1 + v2 + v3 + v4 + v5 + v6 + v7 + u1 + u2 + u3 + u4 + N::v1
+        + N::v2 + N::v3 + S::f();
+    return b;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/compilerplugins/clang/test/externvar.hxx b/compilerplugins/clang/test/externvar.hxx
new file mode 100644
index 0000000..225f1ee
--- /dev/null
+++ b/compilerplugins/clang/test/externvar.hxx
@@ -0,0 +1,27 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INClUDED_COMPILERPLUGINS_CLANG_TEST_EXTERNVAR_HXX
+#define INClUDED_COMPILERPLUGINS_CLANG_TEST_EXTERNVAR_HXX
+
+extern int v1;
+
+namespace N {
+
+extern int v1;
+
+}
+
+struct S;
+
+int f(int a);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk
index a4c0a15..4934ae2 100644
--- a/solenv/CompilerTest_compilerplugins_clang.mk
+++ b/solenv/CompilerTest_compilerplugins_clang.mk
@@ -11,6 +11,7 @@ $(eval $(call gb_CompilerTest_CompilerTest,compilerplugins_clang))
 
 $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
     compilerplugins/clang/test/datamembershadow \
+    compilerplugins/clang/test/externvar \
     compilerplugins/clang/test/finalprotected \
     compilerplugins/clang/test/passstuffbyref \
     compilerplugins/clang/test/oslendian-1 \
commit 6f710c79e23c7f9a02c652180845f61a81c00113
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:44:18 2017 +0100

    New loplugin:externvar: canvas
    
    Change-Id: If11977a086dd7bd7d76782577db619fd272e814c

diff --git a/canvas/source/cairo/cairo_services.cxx b/canvas/source/cairo/cairo_services.cxx
index 10c0e31..0c484d3 100644
--- a/canvas/source/cairo/cairo_services.cxx
+++ b/canvas/source/cairo/cairo_services.cxx
@@ -51,7 +51,7 @@ namespace cairocanvas
         return xRet;
     }
 
-    sdecl::class_< Canvas, sdecl::with_args<true> > serviceImpl1(&initCanvas);
+    sdecl::class_< Canvas, sdecl::with_args<true> > const serviceImpl1(&initCanvas);
     const sdecl::ServiceDecl cairoCanvasDecl(
         serviceImpl1,
         CANVAS_IMPLEMENTATION_NAME,
@@ -65,7 +65,7 @@ namespace cairocanvas
     }
 
     namespace sdecl = comphelper::service_decl;
-    sdecl::class_< SpriteCanvas, sdecl::with_args<true> > serviceImpl2(&initSpriteCanvas);
+    sdecl::class_< SpriteCanvas, sdecl::with_args<true> > const serviceImpl2(&initSpriteCanvas);
     const sdecl::ServiceDecl cairoSpriteCanvasDecl(
         serviceImpl2,
         SPRITECANVAS_IMPLEMENTATION_NAME,
diff --git a/canvas/source/opengl/ogl_spritecanvas.cxx b/canvas/source/opengl/ogl_spritecanvas.cxx
index c3bc92a..8e9cbb8 100644
--- a/canvas/source/opengl/ogl_spritecanvas.cxx
+++ b/canvas/source/opengl/ogl_spritecanvas.cxx
@@ -175,7 +175,7 @@ namespace oglcanvas
         return xRet;
     }
 
-    sdecl::class_<SpriteCanvas, sdecl::with_args<true> > serviceImpl(&initCanvas);
+    sdecl::class_<SpriteCanvas, sdecl::with_args<true> > const serviceImpl(&initCanvas);
     const sdecl::ServiceDecl oglSpriteCanvasDecl(
         serviceImpl,
         SPRITECANVAS_IMPLEMENTATION_NAME,
diff --git a/canvas/source/vcl/services.cxx b/canvas/source/vcl/services.cxx
index 001160c..1417c78 100644
--- a/canvas/source/vcl/services.cxx
+++ b/canvas/source/vcl/services.cxx
@@ -52,7 +52,7 @@ namespace vclcanvas
         return xRet;
     }
 
-    sdecl::class_<Canvas, sdecl::with_args<true> > serviceImpl1(&initCanvas);
+    sdecl::class_<Canvas, sdecl::with_args<true> > const serviceImpl1(&initCanvas);
     const sdecl::ServiceDecl vclCanvasDecl(
         serviceImpl1,
         CANVAS_IMPLEMENTATION_NAME,
@@ -65,7 +65,7 @@ namespace vclcanvas
         return xRet;
     }
 
-    sdecl::class_<SpriteCanvas, sdecl::with_args<true> > serviceImpl2(&initSpriteCanvas);
+    sdecl::class_<SpriteCanvas, sdecl::with_args<true> > const serviceImpl2(&initSpriteCanvas);
     const sdecl::ServiceDecl vclSpriteCanvasDecl(
         serviceImpl2,
         SPRITECANVAS_IMPLEMENTATION_NAME,
commit 3a639ccf74f4c0e3ca6ef24ab54703c350d67896
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:44:10 2017 +0100

    New loplugin:externvar: connectivity
    
    Change-Id: I7e62a92ee4b019163de797fd4448170a741879dc

diff --git a/connectivity/source/drivers/mork/MorkParser.cxx b/connectivity/source/drivers/mork/MorkParser.cxx
index c2b931e..b188e85 100644
--- a/connectivity/source/drivers/mork/MorkParser.cxx
+++ b/connectivity/source/drivers/mork/MorkParser.cxx
@@ -43,12 +43,9 @@
 #include <iostream>
 #include <algorithm>
 
-std::string g_Empty = "";
+std::string const g_Empty = "";
 
-// Mork header of supported format version
-const char *MorkMagicHeader = "// <!-- <mdb:mork:z v=\"1.4\"/> -->";
-
-const char *MorkDictColumnMeta = "<(a=c)>";
+const char * const MorkDictColumnMeta = "<(a=c)>";
 
 static const int defaultScope_ = 0x80;
 
@@ -574,7 +571,7 @@ MorkRowMap *MorkParser::getRows( int RowScope, RowScopeMap *table )
     return &iter->second;
 }
 
-std::string &MorkParser::getValue( int oid )
+std::string const &MorkParser::getValue( int oid )
 {
     MorkDict::iterator foundIter = values_.find( oid );
 
@@ -586,7 +583,7 @@ std::string &MorkParser::getValue( int oid )
     return foundIter->second;
 }
 
-std::string &MorkParser::getColumn( int oid )
+std::string const &MorkParser::getColumn( int oid )
 {
     MorkDict::iterator foundIter = columns_.find( oid );
 
diff --git a/connectivity/source/drivers/mork/MorkParser.hxx b/connectivity/source/drivers/mork/MorkParser.hxx
index fcbdd6a..63cf972 100644
--- a/connectivity/source/drivers/mork/MorkParser.hxx
+++ b/connectivity/source/drivers/mork/MorkParser.hxx
@@ -85,11 +85,11 @@ public:
 
     /// Return value of specified value oid
 
-    std::string &getValue( int oid );
+    std::string const &getValue( int oid );
 
     /// Return value of specified column oid
 
-    std::string &getColumn( int oid );
+    std::string const &getColumn( int oid );
 
     void retrieveLists(std::set<std::string>& lists);
     void getRecordKeysForListTable(std::string& listName, std::set<int>& records);
diff --git a/connectivity/source/drivers/odbc/ORealDriver.cxx b/connectivity/source/drivers/odbc/ORealDriver.cxx
index 0178027..7c88c32 100644
--- a/connectivity/source/drivers/odbc/ORealDriver.cxx
+++ b/connectivity/source/drivers/odbc/ORealDriver.cxx
@@ -24,70 +24,6 @@
 
 namespace connectivity
 {
-    // extern declaration of the function pointer
-    extern T3SQLAllocHandle pODBC3SQLAllocHandle;
-    extern T3SQLConnect pODBC3SQLConnect;
-    extern T3SQLDriverConnect pODBC3SQLDriverConnect;
-    extern T3SQLBrowseConnect pODBC3SQLBrowseConnect;
-    extern T3SQLDataSources pODBC3SQLDataSources;
-    extern T3SQLDrivers pODBC3SQLDrivers;
-    extern T3SQLGetInfo pODBC3SQLGetInfo;
-    extern T3SQLGetFunctions pODBC3SQLGetFunctions;
-    extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
-    extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
-    extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
-    extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
-    extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
-    extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
-    extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
-    //extern T3SQLSetDescField pODBC3SQLSetDescField;
-    //extern T3SQLGetDescField pODBC3SQLGetDescField;
-    //extern T3SQLGetDescRec pODBC3SQLGetDescRec;
-    //extern T3SQLSetDescRec pODBC3SQLSetDescRec;
-    extern T3SQLPrepare pODBC3SQLPrepare;
-    extern T3SQLBindParameter pODBC3SQLBindParameter;
-    //extern T3SQLGetCursorName pODBC3SQLGetCursorName;
-    extern T3SQLSetCursorName pODBC3SQLSetCursorName;
-    extern T3SQLExecute pODBC3SQLExecute;
-    extern T3SQLExecDirect pODBC3SQLExecDirect;
-    //extern T3SQLNativeSql pODBC3SQLNativeSql;
-    extern T3SQLDescribeParam pODBC3SQLDescribeParam;
-    extern T3SQLNumParams pODBC3SQLNumParams;
-    extern T3SQLParamData pODBC3SQLParamData;
-    extern T3SQLPutData pODBC3SQLPutData;
-    extern T3SQLRowCount pODBC3SQLRowCount;
-    extern T3SQLNumResultCols pODBC3SQLNumResultCols;
-    extern T3SQLDescribeCol pODBC3SQLDescribeCol;
-    extern T3SQLColAttribute pODBC3SQLColAttribute;
-    extern T3SQLBindCol pODBC3SQLBindCol;
-    extern T3SQLFetch pODBC3SQLFetch;
-    extern T3SQLFetchScroll pODBC3SQLFetchScroll;
-    extern T3SQLGetData pODBC3SQLGetData;
-    extern T3SQLSetPos pODBC3SQLSetPos;
-    extern T3SQLBulkOperations pODBC3SQLBulkOperations;
-    extern T3SQLMoreResults pODBC3SQLMoreResults;
-    //extern T3SQLGetDiagField pODBC3SQLGetDiagField;
-    extern T3SQLGetDiagRec pODBC3SQLGetDiagRec;
-    extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
-    extern T3SQLColumns pODBC3SQLColumns;
-    extern T3SQLForeignKeys pODBC3SQLForeignKeys;
-    extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
-    extern T3SQLProcedureColumns pODBC3SQLProcedureColumns;
-    extern T3SQLProcedures pODBC3SQLProcedures;
-    extern T3SQLSpecialColumns pODBC3SQLSpecialColumns;
-    extern T3SQLStatistics pODBC3SQLStatistics;
-    extern T3SQLTablePrivileges pODBC3SQLTablePrivileges;
-    extern T3SQLTables pODBC3SQLTables;
-    extern T3SQLFreeStmt pODBC3SQLFreeStmt;
-    extern T3SQLCloseCursor pODBC3SQLCloseCursor;
-    extern T3SQLCancel pODBC3SQLCancel;
-    extern T3SQLEndTran pODBC3SQLEndTran;
-    extern T3SQLDisconnect pODBC3SQLDisconnect;
-    extern T3SQLFreeHandle pODBC3SQLFreeHandle;
-    extern T3SQLGetCursorName pODBC3SQLGetCursorName;
-    extern T3SQLNativeSql pODBC3SQLNativeSql;
-
-
     namespace odbc
     {
         class ORealObdcDriver : public ODBCDriver
diff --git a/connectivity/source/inc/odbc/OFunctions.hxx b/connectivity/source/inc/odbc/OFunctions.hxx
index ff9eaca..2ad9043 100644
--- a/connectivity/source/inc/odbc/OFunctions.hxx
+++ b/connectivity/source/inc/odbc/OFunctions.hxx
@@ -541,6 +541,69 @@ bool LoadLibrary_ODBC3(OUString &_rPath);
                                                     SQLINTEGER *            TextLength2Ptr);
 
     #define N3SQLNativeSql(a,b,c,d,e,f) (*reinterpret_cast<T3SQLNativeSql>(getOdbcFunction(ODBC3SQLFunctionId::NativeSql)))(a,b,c,d,e,f)
+
+    // extern declaration of the function pointer
+    extern T3SQLAllocHandle pODBC3SQLAllocHandle;
+    extern T3SQLConnect pODBC3SQLConnect;
+    extern T3SQLDriverConnect pODBC3SQLDriverConnect;
+    extern T3SQLBrowseConnect pODBC3SQLBrowseConnect;
+    extern T3SQLDataSources pODBC3SQLDataSources;
+    extern T3SQLDrivers pODBC3SQLDrivers;
+    extern T3SQLGetInfo pODBC3SQLGetInfo;
+    extern T3SQLGetFunctions pODBC3SQLGetFunctions;
+    extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
+    extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
+    extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
+    extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
+    extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
+    extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
+    extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
+    //extern T3SQLSetDescField pODBC3SQLSetDescField;
+    //extern T3SQLGetDescField pODBC3SQLGetDescField;
+    //extern T3SQLGetDescRec pODBC3SQLGetDescRec;
+    //extern T3SQLSetDescRec pODBC3SQLSetDescRec;
+    extern T3SQLPrepare pODBC3SQLPrepare;
+    extern T3SQLBindParameter pODBC3SQLBindParameter;
+    //extern T3SQLGetCursorName pODBC3SQLGetCursorName;
+    extern T3SQLSetCursorName pODBC3SQLSetCursorName;
+    extern T3SQLExecute pODBC3SQLExecute;
+    extern T3SQLExecDirect pODBC3SQLExecDirect;
+    //extern T3SQLNativeSql pODBC3SQLNativeSql;
+    extern T3SQLDescribeParam pODBC3SQLDescribeParam;
+    extern T3SQLNumParams pODBC3SQLNumParams;
+    extern T3SQLParamData pODBC3SQLParamData;
+    extern T3SQLPutData pODBC3SQLPutData;
+    extern T3SQLRowCount pODBC3SQLRowCount;
+    extern T3SQLNumResultCols pODBC3SQLNumResultCols;
+    extern T3SQLDescribeCol pODBC3SQLDescribeCol;
+    extern T3SQLColAttribute pODBC3SQLColAttribute;
+    extern T3SQLBindCol pODBC3SQLBindCol;
+    extern T3SQLFetch pODBC3SQLFetch;
+    extern T3SQLFetchScroll pODBC3SQLFetchScroll;
+    extern T3SQLGetData pODBC3SQLGetData;
+    extern T3SQLSetPos pODBC3SQLSetPos;
+    extern T3SQLBulkOperations pODBC3SQLBulkOperations;
+    extern T3SQLMoreResults pODBC3SQLMoreResults;
+    //extern T3SQLGetDiagField pODBC3SQLGetDiagField;
+    extern T3SQLGetDiagRec pODBC3SQLGetDiagRec;
+    extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
+    extern T3SQLColumns pODBC3SQLColumns;
+    extern T3SQLForeignKeys pODBC3SQLForeignKeys;
+    extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
+    extern T3SQLProcedureColumns pODBC3SQLProcedureColumns;
+    extern T3SQLProcedures pODBC3SQLProcedures;
+    extern T3SQLSpecialColumns pODBC3SQLSpecialColumns;
+    extern T3SQLStatistics pODBC3SQLStatistics;
+    extern T3SQLTablePrivileges pODBC3SQLTablePrivileges;
+    extern T3SQLTables pODBC3SQLTables;
+    extern T3SQLFreeStmt pODBC3SQLFreeStmt;
+    extern T3SQLCloseCursor pODBC3SQLCloseCursor;
+    extern T3SQLCancel pODBC3SQLCancel;
+    extern T3SQLEndTran pODBC3SQLEndTran;
+    extern T3SQLDisconnect pODBC3SQLDisconnect;
+    extern T3SQLFreeHandle pODBC3SQLFreeHandle;
+    extern T3SQLGetCursorName pODBC3SQLGetCursorName;
+    extern T3SQLNativeSql pODBC3SQLNativeSql;
 }
 
 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OFUNCTIONS_HXX
diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y
index 28c45f2..e88d394 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -4272,6 +4272,8 @@ using namespace ::com::sun::star::util;
 using namespace ::osl;
 using namespace ::dbtools;
 
+connectivity::OSQLParser* xxx_pGLOBAL_SQLPARSER;
+
 connectivity::OSQLInternalNode* newNode(const sal_Char* pNewValue,
         const connectivity::SQLNodeType eNodeType,
         const sal_uInt32 nNodeID)
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index 52311a0e..c588e2d 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -70,8 +70,6 @@ using namespace ::osl;
 using namespace ::dbtools;
 using namespace ::comphelper;
 
-connectivity::OSQLParser* xxx_pGLOBAL_SQLPARSER;
-
 namespace
 {
 
commit a98334bc42de258ba63f8a9269bd50f84cf3ba7c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:44:01 2017 +0100

    New loplugin:externvar: dbaccess
    
    Change-Id: Ie1b87180b68c1f106128f0fc7a3a591c055b735f

diff --git a/dbaccess/source/core/misc/services.cxx b/dbaccess/source/core/misc/services.cxx
index 70a15d3..80c20a1 100644
--- a/dbaccess/source/core/misc/services.cxx
+++ b/dbaccess/source/core/misc/services.cxx
@@ -29,7 +29,7 @@ using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::registry;
 
 namespace dba{
-    ::cppu::ImplementationEntry entries[] = {
+    ::cppu::ImplementationEntry const entries[] = {
         {
             &::dbaccess::DatabaseDataProvider::Create,
             &::dbaccess::DatabaseDataProvider::getImplementationName_Static,
diff --git a/dbaccess/source/ui/querydesign/LimitBox.cxx b/dbaccess/source/ui/querydesign/LimitBox.cxx
index 6575ad1..ef1d140 100644
--- a/dbaccess/source/ui/querydesign/LimitBox.cxx
+++ b/dbaccess/source/ui/querydesign/LimitBox.cxx
@@ -18,7 +18,7 @@
 namespace global{
 
 /// Default values
-sal_Int64 aDefLimitAry[] =
+sal_Int64 const aDefLimitAry[] =
 {
     5,
     10,
commit a694748f93d8904c44cff0bdf88c9d84b9dcab6f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:43:49 2017 +0100

    New loplugin:externvar: desktop
    
    Change-Id: I3942e7496c6014c0118a9e90a8fa8251bffe8443

diff --git a/desktop/source/deployment/dp_log.cxx b/desktop/source/deployment/dp_log.cxx
index 1e7daa7..74a53eb 100644
--- a/desktop/source/deployment/dp_log.cxx
+++ b/desktop/source/deployment/dp_log.cxx
@@ -19,6 +19,7 @@
 
 
 #include "dp_misc.h"
+#include "dp_services.hxx"
 #include <rtl/strbuf.hxx>
 #include <osl/time.h>
 #include <osl/thread.h>
@@ -185,8 +186,8 @@ void ProgressLogImpl::pop() throw (RuntimeException, std::exception)
 }
 
 namespace sdecl = comphelper::service_decl;
-sdecl::class_<ProgressLogImpl, sdecl::with_args<true> > servicePLI;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::class_<ProgressLogImpl, sdecl::with_args<true> > const servicePLI;
+sdecl::ServiceDecl const serviceDecl(
     servicePLI,
     // a private one:
     "com.sun.star.comp.deployment.ProgressLog",
diff --git a/desktop/source/deployment/dp_services.cxx b/desktop/source/deployment/dp_services.cxx
index b20a266..18c2f88 100644
--- a/desktop/source/deployment/dp_services.cxx
+++ b/desktop/source/deployment/dp_services.cxx
@@ -20,54 +20,11 @@
 
 #include <comphelper/servicedecl.hxx>
 
+#include <dp_services.hxx>
+
 using namespace com::sun::star;
 namespace sdecl = comphelper::service_decl;
 
-namespace dp_registry {
-namespace backend {
-
-namespace configuration {
-extern sdecl::ServiceDecl const serviceDecl;
-}
-
-namespace component {
-extern sdecl::ServiceDecl const serviceDecl;
-}
-
-namespace script {
-extern sdecl::ServiceDecl const serviceDecl;
-}
-
-namespace sfwk {
-extern sdecl::ServiceDecl const serviceDecl;
-}
-
-namespace help {
-extern sdecl::ServiceDecl const serviceDecl;
-}
-
-namespace executable {
-extern sdecl::ServiceDecl const serviceDecl;
-}
-
-} // namespace backend
-} // namespace dp_registry
-
-namespace dp_manager {
-namespace factory {
-extern sdecl::ServiceDecl const serviceDecl;
-}
-extern sdecl::ServiceDecl const serviceDecl;
-}
-
-namespace dp_log {
-extern sdecl::ServiceDecl const serviceDecl;
-}
-
-namespace dp_info {
-extern sdecl::ServiceDecl const serviceDecl;
-}
-
 extern "C" {
 
 SAL_DLLPUBLIC_EXPORT void * SAL_CALL deployment_component_getFactory(
diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx
index 0014cec..a2e2b59 100644
--- a/desktop/source/deployment/gui/dp_gui_service.cxx
+++ b/desktop/source/deployment/gui/dp_gui_service.cxx
@@ -299,19 +299,19 @@ void ServiceImpl::trigger( OUString const &rEvent ) throw (RuntimeException, std
     startExecuteModal( Reference< ui::dialogs::XDialogClosedListener >() );
 }
 
-sdecl::class_<ServiceImpl, sdecl::with_args<true> > serviceSI;
+sdecl::class_<ServiceImpl, sdecl::with_args<true> > const serviceSI;
 sdecl::ServiceDecl const serviceDecl(
     serviceSI,
     "com.sun.star.comp.deployment.ui.PackageManagerDialog",
     "com.sun.star.deployment.ui.PackageManagerDialog" );
 
-sdecl::class_<LicenseDialog, sdecl::with_args<true> > licenseSI;
+sdecl::class_<LicenseDialog, sdecl::with_args<true> > const licenseSI;
 sdecl::ServiceDecl const licenseDecl(
     licenseSI,
     "com.sun.star.comp.deployment.ui.LicenseDialog",
     "com.sun.star.deployment.ui.LicenseDialog" );
 
-sdecl::class_<UpdateRequiredDialogService, sdecl::with_args<true> > updateSI;
+sdecl::class_<UpdateRequiredDialogService, sdecl::with_args<true> > const updateSI;
 sdecl::ServiceDecl const updateDecl(
     updateSI,
     "com.sun.star.comp.deployment.ui.UpdateRequiredDialog",
diff --git a/desktop/source/deployment/inc/dp_services.hxx b/desktop/source/deployment/inc/dp_services.hxx
new file mode 100644
index 0000000..846e55a
--- /dev/null
+++ b/desktop/source/deployment/inc/dp_services.hxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_SERVICES_HXX
+#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_INC_DP_SERVICES_HXX
+
+#include <sal/config.h>
+
+namespace comphelper { namespace service_decl { class ServiceDecl; } }
+
+namespace dp_info {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace dp_log {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace dp_manager {
+
+namespace factory {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+
+}
+
+namespace dp_registry { namespace backend {
+
+namespace component {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace configuration {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace executable {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace help {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace script {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace sfwk {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx
index 4b471f1..14ee844 100644
--- a/desktop/source/deployment/manager/dp_extensionmanager.cxx
+++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx
@@ -47,6 +47,7 @@
 #include <vcl/svapp.hxx>
 #include "dp_interact.h"
 #include "dp_resource.h"
+#include "dp_services.hxx"
 #include "dp_ucb.h"
 #include "dp_identifier.hxx"
 #include "dp_descriptioninfoset.hxx"
@@ -1439,8 +1440,8 @@ sal_Bool ExtensionManager::isReadOnlyRepository(OUString const & repository)
 
 
 namespace sdecl = comphelper::service_decl;
-sdecl::class_<ExtensionManager> servicePIP;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::class_<ExtensionManager> const servicePIP;
+sdecl::ServiceDecl const serviceDecl(
     servicePIP,
     // a private one:
     "com.sun.star.comp.deployment.ExtensionManager",
diff --git a/desktop/source/deployment/manager/dp_informationprovider.cxx b/desktop/source/deployment/manager/dp_informationprovider.cxx
index 134a822..af64864 100644
--- a/desktop/source/deployment/manager/dp_informationprovider.cxx
+++ b/desktop/source/deployment/manager/dp_informationprovider.cxx
@@ -42,6 +42,7 @@
 #include "dp_dependencies.hxx"
 #include "dp_descriptioninfoset.hxx"
 #include "dp_identifier.hxx"
+#include "dp_services.hxx"
 #include "dp_version.hxx"
 #include "dp_misc.h"
 #include "dp_update.hxx"
@@ -314,8 +315,8 @@ uno::Sequence< uno::Sequence< OUString > > SAL_CALL PackageInformationProvider::
 
 
 namespace sdecl = comphelper::service_decl;
-sdecl::class_<PackageInformationProvider> servicePIP;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::class_<PackageInformationProvider> const servicePIP;
+sdecl::ServiceDecl const serviceDecl(
     servicePIP,
     // a private one:
     "com.sun.star.comp.deployment.PackageInformationProvider",
diff --git a/desktop/source/deployment/manager/dp_managerfac.cxx b/desktop/source/deployment/manager/dp_managerfac.cxx
index bcc4a7a..db2b5f8 100644
--- a/desktop/source/deployment/manager/dp_managerfac.cxx
+++ b/desktop/source/deployment/manager/dp_managerfac.cxx
@@ -20,6 +20,7 @@
 
 #include "dp_manager.h"
 #include "dp_resource.h"
+#include "dp_services.hxx"
 #include <cppuhelper/compbase.hxx>
 #include <comphelper/servicedecl.hxx>
 #include <com/sun/star/deployment/thePackageManagerFactory.hpp>
@@ -65,8 +66,8 @@ public:
 
 
 namespace sdecl = comphelper::service_decl;
-sdecl::class_<PackageManagerFactoryImpl> servicePMFI;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::class_<PackageManagerFactoryImpl> const servicePMFI;
+sdecl::ServiceDecl const serviceDecl(
     servicePMFI,
     // a private one:
     "com.sun.star.comp.deployment.PackageManagerFactory",
diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx
index 58b98af..97b72f3 100644
--- a/desktop/source/deployment/registry/component/dp_component.cxx
+++ b/desktop/source/deployment/registry/component/dp_component.cxx
@@ -21,6 +21,7 @@
 #include "dp_component.hrc"
 #include "dp_backend.h"
 #include "dp_platform.hxx"
+#include "dp_services.hxx"
 #include "dp_ucb.h"
 #include <rtl/string.hxx>
 #include <rtl/strbuf.hxx>
@@ -1722,7 +1723,7 @@ BackendImpl::ComponentsPackageImpl::ComponentsPackageImpl(
 
 namespace sdecl = comphelper::service_decl;
 sdecl::class_<BackendImpl, sdecl::with_args<true> > serviceBI;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::ServiceDecl const serviceDecl(
     serviceBI,
     IMPLEMENTATION_NAME,
     BACKEND_SERVICE_NAME );
diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
index f2f7dfb..b508c8a 100644
--- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx
+++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
@@ -27,6 +27,7 @@
 #if HAVE_FEATURE_EXTENSIONS
 #include "dp_persmap.h"
 #endif
+#include "dp_services.hxx"
 #include "dp_ucb.h"
 #include <rtl/string.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -802,7 +803,7 @@ void BackendImpl::PackageImpl::processPackage_(
 
 namespace sdecl = comphelper::service_decl;
 sdecl::class_<BackendImpl, sdecl::with_args<true> > serviceBI;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::ServiceDecl const serviceDecl(
     serviceBI,
     "com.sun.star.comp.deployment.configuration.PackageRegistryBackend",
     BACKEND_SERVICE_NAME );
diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx
index 430ae5e..c400a0b 100644
--- a/desktop/source/deployment/registry/executable/dp_executable.cxx
+++ b/desktop/source/deployment/registry/executable/dp_executable.cxx
@@ -20,6 +20,7 @@
 
 #include "dp_misc.h"
 #include "dp_backend.h"
+#include "dp_services.hxx"
 #include "dp_ucb.h"
 #include "dp_interact.h"
 #include <rtl/string.hxx>
@@ -310,7 +311,7 @@ bool BackendImpl::ExecutablePackageImpl::getFileAttributes(sal_uInt64& out_Attri
 
 namespace sdecl = comphelper::service_decl;
 sdecl::class_<BackendImpl, sdecl::with_args<true> > serviceBI;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::ServiceDecl const serviceDecl(
     serviceBI,
     "com.sun.star.comp.deployment.executable.PackageRegistryBackend",
     BACKEND_SERVICE_NAME );
diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx
index 84f5244..436452a 100644
--- a/desktop/source/deployment/registry/help/dp_help.cxx
+++ b/desktop/source/deployment/registry/help/dp_help.cxx
@@ -22,6 +22,7 @@
 #include "dp_help.hrc"
 #include "dp_backend.h"
 #include "dp_helpbackenddb.hxx"
+#include "dp_services.hxx"
 #include "dp_ucb.h"
 #include <rtl/uri.hxx>
 #include <osl/file.hxx>
@@ -611,7 +612,7 @@ Reference< ucb::XSimpleFileAccess3 > const & BackendImpl::getFileAccess()
 
 namespace sdecl = comphelper::service_decl;
 sdecl::class_<BackendImpl, sdecl::with_args<true> > serviceBI;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::ServiceDecl const serviceDecl(
     serviceBI,
     "com.sun.star.comp.deployment.help.PackageRegistryBackend",
     BACKEND_SERVICE_NAME );
diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx
index c463b31..43bcdd1 100644
--- a/desktop/source/deployment/registry/script/dp_script.cxx
+++ b/desktop/source/deployment/registry/script/dp_script.cxx
@@ -19,6 +19,7 @@
 
 
 #include "dp_script.hrc"
+#include "dp_services.hxx"
 #include "dp_lib_container.h"
 #include "dp_backend.h"
 #include "dp_ucb.h"
@@ -457,7 +458,7 @@ void BackendImpl::PackageImpl::processPackage_(
 
 namespace sdecl = comphelper::service_decl;
 sdecl::class_<BackendImpl, sdecl::with_args<true> > serviceBI;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::ServiceDecl const serviceDecl(
     serviceBI,
     "com.sun.star.comp.deployment.script.PackageRegistryBackend",
     BACKEND_SERVICE_NAME );
diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx
index e19df09..687e651 100644
--- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx
+++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include "dp_services.hxx"
 #include "dp_sfwk.hrc"
 #include "dp_backend.h"
 #include "dp_ucb.h"
@@ -361,8 +364,8 @@ void BackendImpl::PackageImpl::processPackage_(
 }
 
 namespace sdecl = comphelper::service_decl;
-sdecl::class_<BackendImpl, sdecl::with_args<true> > serviceBI;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::class_<BackendImpl, sdecl::with_args<true> > const serviceBI;
+sdecl::ServiceDecl const serviceDecl(
     serviceBI,
     "com.sun.star.comp.deployment.sfwk.PackageRegistryBackend",
     BACKEND_SERVICE_NAME );
diff --git a/desktop/source/migration/services/cexports.cxx b/desktop/source/migration/services/cexports.cxx
index 8d58e12..9877705 100644
--- a/desktop/source/migration/services/cexports.cxx
+++ b/desktop/source/migration/services/cexports.cxx
@@ -26,7 +26,7 @@
 extern "C"
 {
 
-::cppu::ImplementationEntry oo2_entries [] =
+::cppu::ImplementationEntry const oo2_entries [] =
 {
     {
         migration::BasicMigration_create, migration::BasicMigration_getImplementationName,
diff --git a/desktop/source/migration/services/cexportsoo3.cxx b/desktop/source/migration/services/cexportsoo3.cxx
index faaa5e0..eecb5ee 100644
--- a/desktop/source/migration/services/cexportsoo3.cxx
+++ b/desktop/source/migration/services/cexportsoo3.cxx
@@ -24,7 +24,7 @@
 extern "C"
 {
 
-::cppu::ImplementationEntry oo3_entries [] =
+::cppu::ImplementationEntry const oo3_entries [] =
 {
     {
         migration::OO3ExtensionMigration_create, migration::OO3ExtensionMigration_getImplementationName,
diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index b56477d..7ae5ad4 100644
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -705,7 +705,7 @@ exec_javaldx (Args *args)
 #endif
 
 // has to be a global :(
-oslProcess * volatile g_pProcess = NULL;
+static oslProcess * volatile g_pProcess = NULL;
 
 void sigterm_handler(int ignored)
 {
commit 88d0a86014be135c8a0a8760d763e090d833bf6e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:43:44 2017 +0100

    New loplugin:externvar: editeng
    
    Change-Id: I1668a58f478c63b981c57e68795413f2aab87967

diff --git a/editeng/source/accessibility/AccessibleStaticTextBase.cxx b/editeng/source/accessibility/AccessibleStaticTextBase.cxx
index a3175c0..1e9097e 100644
--- a/editeng/source/accessibility/AccessibleStaticTextBase.cxx
+++ b/editeng/source/accessibility/AccessibleStaticTextBase.cxx
@@ -72,7 +72,7 @@ namespace accessibility
             return ( lhs.Name == rhs.Name && lhs.Value == rhs.Value );
         }
     };
-    sal_Unicode cNewLine(0x0a);
+    sal_Unicode const cNewLine(0x0a);
 
 
     // Static Helper
commit 71d8920b4d31f60307f66e4fb51fb6cfe560e6d8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:43:38 2017 +0100

    New loplugin:externvar: extensions
    
    Change-Id: I596eecab083092cccbe67062ade2279e6e25baab

diff --git a/extensions/source/bibliography/bibmod.cxx b/extensions/source/bibliography/bibmod.cxx
index ad627cd..60ec774 100644
--- a/extensions/source/bibliography/bibmod.cxx
+++ b/extensions/source/bibliography/bibmod.cxx
@@ -24,6 +24,7 @@
 #include <com/sun/star/lang/XLocalizable.hpp>
 
 #include "bibmod.hxx"
+#include "bibprop.hrc"
 #include "bibview.hxx"
 #include "bibresid.hxx"
 #include "datman.hxx"
diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx
index b0d763b..eb8bf79 100644
--- a/extensions/source/bibliography/datman.cxx
+++ b/extensions/source/bibliography/datman.cxx
@@ -607,11 +607,11 @@ void SAL_CALL BibInterceptorHelper::setMasterDispatchProvider( const css::uno::R
 
 
 #define STR_UID "uid"
-OUString gGridName("theGrid");
-OUString gViewName("theView");
-OUString gGlobalName("theGlobals");
-OUString gBeamerSize("theBeamerSize");
-OUString gViewSize("theViewSize");
+OUString const gGridName("theGrid");
+OUString const gViewName("theView");
+OUString const gGlobalName("theGlobals");
+OUString const gBeamerSize("theBeamerSize");
+OUString const gViewSize("theViewSize");
 
 BibDataManager::BibDataManager()
     :BibDataManager_Base( GetMutex() )
diff --git a/extensions/source/resource/resourceservices.cxx b/extensions/source/resource/resourceservices.cxx
index fea575e..f8af057 100644
--- a/extensions/source/resource/resourceservices.cxx
+++ b/extensions/source/resource/resourceservices.cxx
@@ -15,8 +15,8 @@
 
 namespace sdecl = ::comphelper::service_decl;
 
-sdecl::class_< ::extensions::resource::ResourceIndexAccess, sdecl::with_args<true> > ResourceIndexAccessServiceImpl;
-sdecl::class_< ::extensions::resource::OpenOfficeResourceLoader> OpenOfficeResourceLoaderServiceImpl;
+sdecl::class_< ::extensions::resource::ResourceIndexAccess, sdecl::with_args<true> > const ResourceIndexAccessServiceImpl;
+sdecl::class_< ::extensions::resource::OpenOfficeResourceLoader> const OpenOfficeResourceLoaderServiceImpl;
 
 const sdecl::ServiceDecl ResourceIndexAccessDecl(
     ResourceIndexAccessServiceImpl,
commit f89aec26a57aae8436a7ecf3ccc29117018cda46
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:43:32 2017 +0100

    New loplugin:externvar: filter
    
    Change-Id: I2f800da9b61f33c801e1bc2809378ac19f22171b

diff --git a/filter/source/flash/swfexporter.cxx b/filter/source/flash/swfexporter.cxx
index 82833f7..9aa7b7f 100644
--- a/filter/source/flash/swfexporter.cxx
+++ b/filter/source/flash/swfexporter.cxx
@@ -386,7 +386,7 @@ sal_uInt16 FlashExporter::exportBackgrounds( Reference< XDrawPage > const & xDra
 }
 
 
-sal_Int32 nPlaceDepth;
+static sal_Int32 nPlaceDepth;
 // AS: A Slide can have a private background or use its masterpage's background.
 //  We use the checksums on the metafiles to tell if backgrounds are the same and
 //  should be reused.  The return value indicates which slide's background to use.
diff --git a/filter/source/graphic/Services.cxx b/filter/source/graphic/Services.cxx
index 13d0969..d4742ac 100644
--- a/filter/source/graphic/Services.cxx
+++ b/filter/source/graphic/Services.cxx
@@ -24,13 +24,13 @@
 #define GRAPHIC_EXPORT_FILTER_SERVICE "com.sun.star.comp.GraphicExportFilter"
 #define GRAPHIC_EXPORT_DIALOG_SERVICE "com.sun.star.comp.GraphicExportDialog"
 
-comphelper::service_decl::class_<GraphicExportFilter> serviceGraphicExportFilter;
+comphelper::service_decl::class_<GraphicExportFilter> const serviceGraphicExportFilter;
 const comphelper::service_decl::ServiceDecl graphicExportFilter(
     serviceGraphicExportFilter,
     GRAPHIC_EXPORT_FILTER_SERVICE,
     "com.sun.star.document.ExportFilter" );
 
-comphelper::service_decl::class_<GraphicExportDialog> serviceGraphicExportDialog;
+comphelper::service_decl::class_<GraphicExportDialog> const serviceGraphicExportDialog;
 const comphelper::service_decl::ServiceDecl graphicExportDialog(
     serviceGraphicExportDialog,
     GRAPHIC_EXPORT_DIALOG_SERVICE,
diff --git a/filter/source/msfilter/msocximex.cxx b/filter/source/msfilter/msocximex.cxx
index 7848448..58c8266 100644
--- a/filter/source/msfilter/msocximex.cxx
+++ b/filter/source/msfilter/msocximex.cxx
@@ -30,7 +30,7 @@
 
 using namespace ::com::sun::star;
 
-OUString sWW8_form( "WW-Standard" );
+OUString const sWW8_form( "WW-Standard" );
 
 SvxMSConvertOCXControls::SvxMSConvertOCXControls( const uno::Reference< frame::XModel >& rxModel) : mxModel(rxModel)
 {
diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx
index addc6b0..8577f35 100644
--- a/filter/source/msfilter/msvbahelper.cxx
+++ b/filter/source/msfilter/msvbahelper.cxx
@@ -642,7 +642,7 @@ struct KeyCodeEntry
    sal_uInt16 nCode;
 };
 
-KeyCodeEntry aMSKeyCodesData[] = {
+KeyCodeEntry const aMSKeyCodesData[] = {
     { "BACKSPACE", KEY_BACKSPACE },
     { "BS", KEY_BACKSPACE },
     { "DELETE", KEY_DELETE },
@@ -684,7 +684,7 @@ awt::KeyEvent parseKeyEvent( const OUString& Key ) throw ( uno::RuntimeException
     static std::map< OUString, sal_uInt16 > s_KeyCodes;
     if ( s_KeyCodes.empty() )
     {
-        for (KeyCodeEntry & i : aMSKeyCodesData)
+        for (KeyCodeEntry const & i : aMSKeyCodesData)
         {
             s_KeyCodes[ OUString::createFromAscii( i.sName ) ] = i.nCode;
         }
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index a47ac18..c8480b1 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -387,7 +387,7 @@ OUString SAL_CALL SVGFilter::detect(Sequence<PropertyValue>& rDescriptor) throw
 #define SVG_WRITER_IMPL_NAME "com.sun.star.comp.Draw.SVGWriter"
 
 namespace sdecl = comphelper::service_decl;
- sdecl::class_<SVGFilter> serviceFilterImpl;
+ sdecl::class_<SVGFilter> const serviceFilterImpl;
  const sdecl::ServiceDecl svgFilter(
      serviceFilterImpl,
      SVG_FILTER_IMPL_NAME,
@@ -395,7 +395,7 @@ namespace sdecl = comphelper::service_decl;
      "com.sun.star.document.ExportFilter;"
      "com.sun.star.document.ExtendedTypeDetection" );
 
- sdecl::class_<SVGWriter, sdecl::with_args<true> > serviceWriterImpl;
+ sdecl::class_<SVGWriter, sdecl::with_args<true> > const serviceWriterImpl;
  const sdecl::ServiceDecl svgWriter(
      serviceWriterImpl,
      SVG_WRITER_IMPL_NAME,
diff --git a/filter/source/t602/t602filter.cxx b/filter/source/t602/t602filter.cxx
index 4b9e772..a7fe34b 100644
--- a/filter/source/t602/t602filter.cxx
+++ b/filter/source/t602/t602filter.cxx
@@ -55,7 +55,7 @@ using com::sun::star::io::XInputStream;
 
 namespace T602ImportFilter {
 
-    unsigned char kam2lat[129] =
+    unsigned char const kam2lat[129] =
         //    0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
         "\xAC\x81\x82\xD4\x84\xD2\x9B\x9F\xD8\xB7\x91\xD6\x96\x92\x8E\xB5"  // 8
         "\x90\xA7\xA6\x93\x94\xE0\x85\xE9\xEC\x99\x9A\xE6\x95\xED\xFC\x9C"  // 9
@@ -66,7 +66,7 @@ namespace T602ImportFilter {
         "\xD0\xD1\xD3\xD7\xAA\xAB\xDD\xB0\xE3\xE4\xEB\xEE\xEF\xF0\xF2\xF4"  // E
         "\xBC\xBD\xBE\xC6\xC7\xC8\xF6\xC9\xCA\xFA\xFB\xCB\xF1\xCC\xFE\xFF"; // F
 
-    unsigned char koi2lat[129] =
+    unsigned char const koi2lat[129] =
         //    0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
         "\x80\x83\x86\xF5\xE1\x87\x88\x89\x8A\x8B\x8C\x8F\x97\xCF\xCF\x98"  // 8
         "\x9D\x9E\xA4\xA5\xA8\xA9\xDB\xDC\xDF\xB1\xB2\xB6\xB8\xB9\xBA\xBB"  // 9
@@ -77,7 +77,7 @@ namespace T602ImportFilter {
         "\xBF\xB5\xD9\xAC\xD2\xB7\xE8\xB3\x9A\xD6\xDE\x91\x95\x99\xD5\xE0"  // E
         "\xE2\x8E\xFC\xE6\x9B\xE9\xB4\x90\xFA\xED\xA6\xC1\xF1\xFB\xFE\xFF"; // F
 
-    unsigned char lat2UNC[257] =
+    unsigned char const lat2UNC[257] =
         //    0       1       2       3       4       5       6       7
         //    8       9       A       B       C       D       E       F
         "\x00\xe7\x00\xfc\x00\xe9\x00\xf9\x00\xe4\x01\x6f\x00\xe8\x00\xa3"  // 8
@@ -97,7 +97,7 @@ namespace T602ImportFilter {
         "\x00\xf8\x02\xdd\x03\xb5\x02\xc7\x22\x29\x00\xa7\x00\xf7\x00\xe0"  // F
         "\x00\xb4\x00\xb0\x00\xc0\x02\xc6\x01\x58\x01\x59\x00\x20\x00\x20";
 
-    unsigned char rus2UNC[257] =
+    unsigned char const rus2UNC[257] =
         //    0       1       2       3       4       5       6       7
         //    8       9       A       B       C       D       E       F
         "\x04\x11\x00\xfc\x00\xe9\x04\x12\x00\xe4\x01\x6f\x04\x13\x04\x14"  // 8
@@ -131,7 +131,7 @@ namespace T602ImportFilter {
         mxHandler->endElement(_nam); \
     }
 
-inistruct ini;
+static inistruct ini;
 
 T602ImportFilter::T602ImportFilter(const css::uno::Reference<css::lang::XMultiServiceFactory > &r )
     : mxMSF(r)
commit a109caf3e2d92f62968998a750acfe8a4d07115f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:43:26 2017 +0100

    New loplugin:externvar: framework
    
    Change-Id: Idcc4e0bb8065d7a9b30d38463470a67b1921c6cb

diff --git a/framework/source/fwe/xml/menudocumenthandler.cxx b/framework/source/fwe/xml/menudocumenthandler.cxx
index 2733337..759244d 100644
--- a/framework/source/fwe/xml/menudocumenthandler.cxx
+++ b/framework/source/fwe/xml/menudocumenthandler.cxx
@@ -103,7 +103,7 @@ const MenuStyleItem MenuItemStyles[ ] = {
     { css::ui::ItemStyle::RADIO_CHECK, ATTRIBUTE_ITEMSTYLE_RADIO }
 };
 
-sal_Int32 nMenuStyleItemEntries = SAL_N_ELEMENTS(MenuItemStyles);
+sal_Int32 const nMenuStyleItemEntries = SAL_N_ELEMENTS(MenuItemStyles);
 
 static void ExtractMenuParameters( const Sequence< PropertyValue >& rProp,
                                    OUString&                       rCommandURL,
diff --git a/framework/source/fwe/xml/statusbardocumenthandler.cxx b/framework/source/fwe/xml/statusbardocumenthandler.cxx
index 16af931..4d7e66a 100644
--- a/framework/source/fwe/xml/statusbardocumenthandler.cxx
+++ b/framework/source/fwe/xml/statusbardocumenthandler.cxx
@@ -128,7 +128,7 @@ struct StatusBarEntryProperty
     char                                                    aEntryName[20];
 };
 
-StatusBarEntryProperty StatusBarEntries[OReadStatusBarDocumentHandler::SB_XML_ENTRY_COUNT] =
+StatusBarEntryProperty const StatusBarEntries[OReadStatusBarDocumentHandler::SB_XML_ENTRY_COUNT] =
 {
     { OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,   ELEMENT_STATUSBAR       },
     { OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,   ELEMENT_STATUSBARITEM   },
diff --git a/framework/source/fwe/xml/toolboxdocumenthandler.cxx b/framework/source/fwe/xml/toolboxdocumenthandler.cxx
index c8c550b..e31da54 100644
--- a/framework/source/fwe/xml/toolboxdocumenthandler.cxx
+++ b/framework/source/fwe/xml/toolboxdocumenthandler.cxx
@@ -99,7 +99,7 @@ const ToolboxStyleItem Styles[ ] = {
     { css::ui::ItemStyle::TEXT,          ATTRIBUTE_ITEMSTYLE_TEXT },
 };
 
-sal_Int32 nStyleItemEntries = SAL_N_ELEMENTS(Styles);
+sal_Int32 const nStyleItemEntries = SAL_N_ELEMENTS(Styles);
 
 struct ToolBarEntryProperty
 {
@@ -107,7 +107,7 @@ struct ToolBarEntryProperty
     char                                                aEntryName[20];
 };
 
-ToolBarEntryProperty ToolBoxEntries[OReadToolBoxDocumentHandler::TB_XML_ENTRY_COUNT] =
+ToolBarEntryProperty const ToolBoxEntries[OReadToolBoxDocumentHandler::TB_XML_ENTRY_COUNT] =
 {
     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ELEMENT_TOOLBAR             },
     { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR,   ELEMENT_TOOLBARITEM         },
diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx
index 913324f..f0b2a19 100644
--- a/framework/source/xml/imagesdocumenthandler.cxx
+++ b/framework/source/xml/imagesdocumenthandler.cxx
@@ -81,7 +81,7 @@ struct ImageXMLEntryProperty
     char                                            aEntryName[20];
 };
 
-ImageXMLEntryProperty ImagesEntries[OReadImagesDocumentHandler::IMG_XML_ENTRY_COUNT] =
+ImageXMLEntryProperty const ImagesEntries[OReadImagesDocumentHandler::IMG_XML_ENTRY_COUNT] =
 {
     { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_IMAGECONTAINER          },
     { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_IMAGES                  },
commit e5cc0021654fde80e19c419242b64f2f88ac75d9
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:43:18 2017 +0100

    New loplugin:externvar: hwpfilter
    
    Change-Id: I275d67b2878400cd0774f21b1a7489a0dd392e82

diff --git a/hwpfilter/source/fontmap.cxx b/hwpfilter/source/fontmap.cxx
index 8de1542..7207e75 100644
--- a/hwpfilter/source/fontmap.cxx
+++ b/hwpfilter/source/fontmap.cxx
@@ -126,7 +126,7 @@ const char* RepFontTab[] =
     "\xb1\xc3\xbc\xad"                                        /* 3 */
 };
 #elif defined(LINUX)
-const char* RepFontTab[] =
+const char* const RepFontTab[] =
 {
     "\xb9\xe9\xb9\xac \xb9\xd9\xc5\xc1",                                     /* 0 */
     "\xb9\xe9\xb9\xac \xb5\xb8\xbf\xf2",                                      /* 1 */
diff --git a/hwpfilter/source/formula.cxx b/hwpfilter/source/formula.cxx
index 9419228..8b6ce28 100644
--- a/hwpfilter/source/formula.cxx
+++ b/hwpfilter/source/formula.cxx
@@ -25,9 +25,6 @@
 #include "mapping.h"
 #include "hwpeq.h"
 #include <iostream>
-#include <list>
-
-extern std::list<Node*> nodelist;
 
 #ifndef DEBUG
 
diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index 80d2d175..a3ce4d3 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -36,11 +36,15 @@
 #include "lexer.hxx"
 #include "nodes.h"
 
+extern "C" {
+#include "grammar.h"
+}
+
 std::list<Node*> nodelist;
 
 void yyerror(const char *);
 
-Node *top=nullptr;
+static Node *top=nullptr;
 
 int Node::count = 0;
 
@@ -50,12 +54,6 @@ int Node::count = 0;
 int debug(const char *format, ...);
 #endif
 
-
-typedef union {
-    char *dval;
-    char *str;
-    Node *ptr;
-} YYSTYPE;
 #include <stdio.h>
 
 #define YYFINAL     102
@@ -389,7 +387,7 @@ static const short yycheck[] = {    11,
 
 #ifndef YYPURE
 
-int yychar;         /*  the lookahead symbol        */
+static int yychar;  /*  the lookahead symbol        */
 YYSTYPE yylval;         /*  the semantic value of the       */
                 /*  lookahead symbol            */
 
@@ -398,7 +396,7 @@ YYLTYPE yylloc;         /*  location data for the lookahead */
                 /*  symbol              */
 #endif
 
-int yynerrs;            /*  number of parse errors so far       */
+static int yynerrs;     /*  number of parse errors so far       */
 #endif  /* not YYPURE */
 
 #if YYDEBUG != 0
diff --git a/hwpfilter/source/lexer.cxx b/hwpfilter/source/lexer.cxx
index 0c52851..915b7b0 100644
--- a/hwpfilter/source/lexer.cxx
+++ b/hwpfilter/source/lexer.cxx
@@ -91,9 +91,6 @@
 
 typedef struct yy_buffer_state *YY_BUFFER_STATE;
 
-extern int yyleng;
-extern FILE *yyin, *yyout;
-
 #define EOB_ACT_CONTINUE_SCAN 0
 #define EOB_ACT_END_OF_FILE 1
 #define EOB_ACT_LAST_MATCH 2
@@ -179,7 +176,7 @@ static char yy_hold_char;
 static int yy_n_chars;      /* number of characters read into yy_ch_buf */
 
 
-int yyleng;
+static int yyleng;
 
 /* Points to current character in buffer. */
 static char *yy_c_buf_p = nullptr;
@@ -209,9 +206,8 @@ static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
 static void yy_flex_free YY_PROTO(( void * ));
 
 typedef unsigned char YY_CHAR;
-FILE *yyin = nullptr, *yyout = nullptr;
+static FILE *yyin = nullptr, *yyout = nullptr;
 typedef int yy_state_type;
-extern char *yytext;
 #define yytext_ptr yytext
 
 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
@@ -933,7 +929,7 @@ static char *yy_last_accepting_cpos;
 
 #define YY_MORE_ADJ 0
 #define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
+static char *yytext;
 #define INITIAL 0
 #include <stdlib.h>
 #include <string.h>
diff --git a/hwpfilter/source/nodes.h b/hwpfilter/source/nodes.h
index 60626c5..01fc85f 100644
--- a/hwpfilter/source/nodes.h
+++ b/hwpfilter/source/nodes.h
@@ -20,6 +20,9 @@
 #ifndef INCLUDED_HWPFILTER_SOURCE_NODES_H
 #define INCLUDED_HWPFILTER_SOURCE_NODES_H
 
+#include <sal/config.h>
+
+#include <list>
 #include <stdio.h>
 #include <stdlib.h>
 #include <osl/diagnose.h>
@@ -92,7 +95,7 @@ public:
      Node *next;
 };
 
-//static LinkedList<Node> nodelist;
+extern std::list<Node *> nodelist;
 
 #endif
 
commit 9c5494bfd781a32882b1cdfa2ab8645df960d85b
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:43:11 2017 +0100

    New loplugin:externvar: idl
    
    Change-Id: I67d0c0f7c7aa6d4a81e46ef6afca2d7a762eb813

diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx
index 057c495..f8cf408 100644
--- a/idl/source/prj/command.cxx
+++ b/idl/source/prj/command.cxx
@@ -31,7 +31,7 @@
 #include <database.hxx>
 #include <parser.hxx>
 
-char const * SyntaxStrings[] = {
+char const * const SyntaxStrings[] = {
 "basic-type:",
 "\tvoid|        char|       int|        float|      double|",
 "\tUINT16|      INT16|      UINT32|     INT32|      BOOL|",
@@ -101,7 +101,7 @@ char const * SyntaxStrings[] = {
 "---syntax example is sfx.idl---\n",
 nullptr };
 
-char CommandLineSyntax[] =
+char const CommandLineSyntax[] =
 "-fs<slotmap file>\n"
 "-fm<makefile target file>\n"
 "-help, ?                   @<file> response file\n"
commit ff7ee9796f93b7cd7a8f80e9efbc42909d509344
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:42:59 2017 +0100

    New loplugin:externvar: i18npool
    
    Change-Id: Id38d1fde0e0f6e08899e83697f586d513b635aad

diff --git a/i18npool/source/collator/chaptercollator.cxx b/i18npool/source/collator/chaptercollator.cxx
index b18e0fc..68315bf 100644
--- a/i18npool/source/collator/chaptercollator.cxx
+++ b/i18npool/source/collator/chaptercollator.cxx
@@ -73,12 +73,12 @@ ChapterCollator::compareSubstring( const OUString& str1, sal_Int32 off1, sal_Int
     return res1.Value == res2.Value ? 0 : res1.Value > res2.Value ? 1 : -1;
 }
 
-const sal_Char *cChapCollator = "com.sun.star.i18n.ChapterCollator";
+const sal_Char cChapCollator[] = "com.sun.star.i18n.ChapterCollator";
 
 OUString SAL_CALL
 ChapterCollator::getImplementationName() throw( RuntimeException, std::exception )
 {
-    return OUString::createFromAscii(cChapCollator);
+    return OUString(cChapCollator);
 }
 
 sal_Bool SAL_CALL
@@ -90,7 +90,7 @@ ChapterCollator::supportsService(const OUString& rServiceName) throw( RuntimeExc
 Sequence< OUString > SAL_CALL
 ChapterCollator::getSupportedServiceNames() throw( RuntimeException, std::exception )
 {
-    Sequence< OUString > aRet { OUString::createFromAscii(cChapCollator) };
+    Sequence< OUString > aRet { cChapCollator };
     return aRet;
 }
 
diff --git a/i18npool/source/inputchecker/inputsequencechecker_hi.cxx b/i18npool/source/inputchecker/inputsequencechecker_hi.cxx
index 1c2036b..c6933bb 100644
--- a/i18npool/source/inputchecker/inputsequencechecker_hi.cxx
+++ b/i18npool/source/inputchecker/inputsequencechecker_hi.cxx
@@ -99,7 +99,7 @@ static const sal_uInt16 dev_cell_check[14][14] = {
   /* 13 */ { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 }  /* HD */
 };
 
-bool DEV_Composible[2][2] = {
+bool const DEV_Composible[2][2] = {
 /* Mode 0 */    {true, true }, // PASSTHROUGH = 0
 /* Mode 1 */    {false, true}  // STRICT = 1
 };
diff --git a/i18npool/source/inputchecker/inputsequencechecker_th.cxx b/i18npool/source/inputchecker/inputsequencechecker_th.cxx
index fa649f1..e16a16a 100644
--- a/i18npool/source/inputchecker/inputsequencechecker_th.cxx
+++ b/i18npool/source/inputchecker/inputsequencechecker_th.cxx
@@ -34,7 +34,7 @@ InputSequenceChecker_th::~InputSequenceChecker_th()
 }
 
 /* Table for Thai Cell Manipulation */
-sal_Char TAC_celltype_inputcheck[17][17] = {
+sal_Char const TAC_celltype_inputcheck[17][17] = {
 /* Cn */ /*  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   A,   B,   C,   D,   E,   F       */
 /* Cn-1 00 */{  'X', 'A', 'A', 'A', 'A', 'A', 'A', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' },
      /* 10 */{  'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' },
@@ -55,7 +55,7 @@ sal_Char TAC_celltype_inputcheck[17][17] = {
          { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', 'R', 'R', 'C', 'R', 'C', 'R', 'R', 'R', 'R' }
 };
 
-bool TAC_Composible[3][5] = {
+bool const TAC_Composible[3][5] = {
         /*  'A',    'C',        'S',        'R',        'X'   */
 /* Mode 0 */    {true,  true,   true,   true,   true}, // PASSTHROUGH = 0
 /* Mode 1 */    {true,  true,   true,   false,      true}, // BASIC = 1
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index 3fd27e5..1567859 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -813,7 +813,7 @@ sal_Int16 SAL_CALL NativeNumberSupplierService::convertFromXmlAttributes( const
 struct HebrewNumberChar {
     sal_Unicode code;
     sal_Int16 value;
-} HebrewNumberCharArray[] = {
+} const HebrewNumberCharArray[] = {
     { 0x05ea, 400 },
     { 0x05ea, 400 },
     { 0x05e9, 300 },
@@ -920,7 +920,7 @@ static sal_Unicode cyrillicTen = 0x0456;
 struct CyrillicNumberChar {
     sal_Unicode code;
     sal_Int16 value;
-} CyrillicNumberCharArray[] = {
+} const CyrillicNumberCharArray[] = {
     { 0x0446, 900 },
     { 0x047f, 800 },
     { 0x0471, 700 },
diff --git a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
index 706f46c..703db16 100644
--- a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
@@ -26,7 +26,7 @@ using namespace com::sun::star::lang;
 
 namespace com { namespace sun { namespace star { namespace i18n {
 
-OneToOneMappingTable_t IandE[] = {
+OneToOneMappingTable_t const IandE[] = {
     { 0x30A3, 0x0000 },  // KATAKANA LETTER SMALL I
     { 0x30A4, 0x0000 },  // KATAKANA LETTER I
     { 0x30A7, 0x0000 },  // KATAKANA LETTER SMALL E
diff --git a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
index f5cacb2..6b01649 100644
--- a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
@@ -27,7 +27,7 @@ using namespace com::sun::star::lang;
 
 namespace com { namespace sun { namespace star { namespace i18n {
 
-OneToOneMappingTable_t ignoreIterationMark_ja_JP_mappingTable[] = {
+OneToOneMappingTable_t const ignoreIterationMark_ja_JP_mappingTable[] = {
     { 0x3046, 0x3094 },  // HIRAGANA LETTER U --> HIRAGANA LETTER VU
     { 0x304B, 0x304C },  // HIRAGANA LETTER KA --> HIRAGANA LETTER GA
     { 0x304D, 0x304E },  // HIRAGANA LETTER KI --> HIRAGANA LETTER GI
diff --git a/i18npool/source/transliteration/ignoreSeparator_ja_JP.cxx b/i18npool/source/transliteration/ignoreSeparator_ja_JP.cxx
index fa2efa4..99e423c 100644
--- a/i18npool/source/transliteration/ignoreSeparator_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreSeparator_ja_JP.cxx
@@ -21,7 +21,7 @@
 
 namespace com { namespace sun { namespace star { namespace i18n {
 
-OneToOneMappingTable_t ignoreSeparatorTable[] = {
+OneToOneMappingTable_t const ignoreSeparatorTable[] = {
     { 0x0021, 0xFFFF },  // EXCLAMATION MARK
     { 0x0023, 0xFFFF },  // NUMBER SIGN
     { 0x0024, 0xFFFF },  // DOLLAR SIGN
diff --git a/i18npool/source/transliteration/ignoreSpace_ja_JP.cxx b/i18npool/source/transliteration/ignoreSpace_ja_JP.cxx
index 4e52786..dbee151 100644
--- a/i18npool/source/transliteration/ignoreSpace_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreSpace_ja_JP.cxx
@@ -21,7 +21,7 @@
 
 namespace com { namespace sun { namespace star { namespace i18n {
 
-OneToOneMappingTable_t ignoreSpace_ja_JP_mappingTable[] = {
+OneToOneMappingTable_t const ignoreSpace_ja_JP_mappingTable[] = {
     { 0x0020, 0xffff },  // SPACE
     { 0x00A0, 0xffff },  // NO-BREAK SPACE
     { 0x2002, 0xffff },  // EN SPACE
diff --git a/i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP.cxx b/i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP.cxx
index 1fa378d..1606c90 100644
--- a/i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP.cxx
@@ -22,7 +22,7 @@
 namespace com { namespace sun { namespace star { namespace i18n {
 
 // traditional Kanji characters --> modern Kanji characters
-OneToOneMappingTable_t traditionalKanji2updateKanji[] = {
+OneToOneMappingTable_t const traditionalKanji2updateKanji[] = {
     { 0x4E17, 0x4E16 },
     { 0x4E55, 0x864E },
     { 0x4E58, 0x4E57 },
diff --git a/i18npool/source/transliteration/largeToSmall_ja_JP.cxx b/i18npool/source/transliteration/largeToSmall_ja_JP.cxx
index f4f62ae..3986336 100644
--- a/i18npool/source/transliteration/largeToSmall_ja_JP.cxx
+++ b/i18npool/source/transliteration/largeToSmall_ja_JP.cxx
@@ -32,7 +32,7 @@ namespace com { namespace sun { namespace star { namespace i18n {
 // http://charts.unicode.org/Web/U30A0.html Katakana (U+30A0..U+30FF)
 // http://charts.unicode.org/Web/UFF00.html
 
-OneToOneMappingTable_t large2small[] = {
+OneToOneMappingTable_t const large2small[] = {
     { 0x3041, 0x3042 },  // HIRAGANA LETTER SMALL A --> HIRAGANA LETTER A
     { 0x3043, 0x3044 },  // HIRAGANA LETTER SMALL I --> HIRAGANA LETTER I
     { 0x3045, 0x3046 },  // HIRAGANA LETTER SMALL U --> HIRAGANA LETTER U
diff --git a/i18npool/source/transliteration/smallToLarge_ja_JP.cxx b/i18npool/source/transliteration/smallToLarge_ja_JP.cxx
index 49827dd..fb48392 100644
--- a/i18npool/source/transliteration/smallToLarge_ja_JP.cxx
+++ b/i18npool/source/transliteration/smallToLarge_ja_JP.cxx
@@ -32,7 +32,7 @@ namespace com { namespace sun { namespace star { namespace i18n {
 // http://charts.unicode.org/Web/U30A0.html Katakana (U+30A0..U+30FF)
 // http://charts.unicode.org/Web/UFF00.html
 
-OneToOneMappingTable_t small2large[] = {
+OneToOneMappingTable_t const small2large[] = {
     { 0x3041, 0x3042 },  // HIRAGANA LETTER SMALL A --> HIRAGANA LETTER A
     { 0x3043, 0x3044 },  // HIRAGANA LETTER SMALL I --> HIRAGANA LETTER I
     { 0x3045, 0x3046 },  // HIRAGANA LETTER SMALL U --> HIRAGANA LETTER U
diff --git a/i18nutil/source/utility/oneToOneMapping.cxx b/i18nutil/source/utility/oneToOneMapping.cxx
index bef181b..0ebe66f 100644
--- a/i18nutil/source/utility/oneToOneMapping.cxx
+++ b/i18nutil/source/utility/oneToOneMapping.cxx
@@ -21,7 +21,7 @@
 
 namespace com { namespace sun { namespace star { namespace i18n {
 
-oneToOneMapping::oneToOneMapping( OneToOneMappingTable_t *rpTable, const size_t rnBytes, const size_t rnUnitSize )
+oneToOneMapping::oneToOneMapping( OneToOneMappingTable_t const *rpTable, const size_t rnBytes, const size_t rnUnitSize )
     : mpTable( rpTable ),
       mnSize( rnBytes / rnUnitSize )
 {
diff --git a/include/i18nutil/oneToOneMapping.hxx b/include/i18nutil/oneToOneMapping.hxx
index 7b9e38a..a4f3f09 100644
--- a/include/i18nutil/oneToOneMapping.hxx
+++ b/include/i18nutil/oneToOneMapping.hxx
@@ -46,7 +46,7 @@ private:
     oneToOneMapping(const oneToOneMapping&) = delete;
     oneToOneMapping& operator=(const oneToOneMapping&) = delete;
 public:
-    oneToOneMapping( OneToOneMappingTable_t *rpTable, const size_t rnSize, const size_t rnUnitSize = sizeof(OneToOneMappingTable_t) );
+    oneToOneMapping( OneToOneMappingTable_t const *rpTable, const size_t rnSize, const size_t rnUnitSize = sizeof(OneToOneMappingTable_t) );
     virtual ~oneToOneMapping();
 
     // binary search
@@ -56,7 +56,7 @@ public:
     sal_Unicode operator[] ( const sal_Unicode nKey ) const { return find( nKey ); };
 
 protected:
-    OneToOneMappingTable_t *mpTable;
+    OneToOneMappingTable_t const *mpTable;
     size_t                  mnSize;
 };
 
commit 6e50fef4c055b2110328dc820038f41fc6c85530
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:42:43 2017 +0100

    New loplugin:externvar: idlc
    
    Change-Id: I7b892efd6a5267c228c4cf17e80fac82628fbb64

diff --git a/idlc/source/idlccompile.cxx b/idlc/source/idlccompile.cxx
index 1f62871..5066752 100644
--- a/idlc/source/idlccompile.cxx
+++ b/idlc/source/idlccompile.cxx
@@ -48,9 +48,6 @@ extern int yyparse();
 extern FILE* yyin;
 extern int yydebug;
 
-sal_Int32 lineNumber = 1;
-
-
 static sal_Char tmpFilePattern[512];
 
 bool isFileUrl(const OString& fileName)
diff --git a/idlc/source/idlcproduce.cxx b/idlc/source/idlcproduce.cxx
index ab4e52c..67da2cd 100644
--- a/idlc/source/idlcproduce.cxx
+++ b/idlc/source/idlcproduce.cxx
@@ -39,7 +39,7 @@
 
 using namespace ::osl;
 
-std::list< OString >* pCreatedDirectories = nullptr;
+static std::list< OString >* pCreatedDirectories = nullptr;
 
 static bool checkOutputPath(const OString& completeName)
 {
commit 884437ef2e8f6739e149c96be5992253c3720bcb
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:42:37 2017 +0100

    New loplugin:externvar: jvmfwk
    
    Change-Id: I0fee834ba07ecdc713e0e066935773f49a109665

diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index d1a0088..65fe642 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -115,8 +115,6 @@ char const *g_arSearchPaths[] = {
 
 namespace jfw_plugin
 {
-extern VendorSupportMapEntry gVendorMap[];
-
 #if defined(_WIN32)
 bool getSDKInfoFromRegistry(vector<OUString> & vecHome);
 bool getJREInfoFromRegistry(vector<OUString>& vecJavaHome);
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx b/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx
index 553c9f9..3947a4d6 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/vendorlist.hxx
@@ -35,6 +35,8 @@ struct VendorSupportMapEntry
     createInstance_func  createFunc;
 };
 
+extern VendorSupportMapEntry gVendorMap[];
+
 #define BEGIN_VENDOR_MAP() \
 VendorSupportMapEntry gVendorMap[] ={
 
diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx
index b7d1d91..6eacf33 100644
--- a/jvmfwk/source/fwkbase.cxx
+++ b/jvmfwk/source/fwkbase.cxx
@@ -43,7 +43,7 @@ using namespace osl;
 
 namespace jfw
 {
-bool  g_bJavaSet = false;
+static bool  g_bJavaSet = false;
 
 namespace {
 
commit d5f2ba9a3ebf952cb237141dae33ba9fc06ddabd
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:42:29 2017 +0100

    New loplugin:externvar: l10ntools
    
    Change-Id: I7bfad0dfff95667a33b48dfe2354a8f0ffc5060d

diff --git a/l10ntools/source/uimerge.cxx b/l10ntools/source/uimerge.cxx
index 5b05dc9..dd334de 100644
--- a/l10ntools/source/uimerge.cxx
+++ b/l10ntools/source/uimerge.cxx
@@ -29,8 +29,8 @@
 #include <fstream>
 #include <vector>
 
-OString sInputFileName;
-OString sOutputFile;
+static OString sInputFileName;
+static OString sOutputFile;
 
 int extractTranslations()
 {
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index 0feb4e0..2bebcfe 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -40,16 +40,16 @@ using namespace std;
 void yyerror( const char * );
 
 // set of global variables
-bool bMergeMode;
-bool bDisplayName;
-bool bExtensionDescription;
-OString sLanguage;
-OString sInputFileName;
-OString sOutputFile;
-OString sMergeSrc;
-OString sLangAttribute;
-OString sResourceType;
-XRMResParser *pParser = nullptr;
+static bool bMergeMode;
+static bool bDisplayName;
+static bool bExtensionDescription;
+static OString sLanguage;
+static OString sInputFileName;
+static OString sOutputFile;
+static OString sMergeSrc;
+static OString sLangAttribute;
+static OString sResourceType;
+static XRMResParser *pParser = nullptr;
 
 extern "C" {
 // the whole interface to lexer is in this extern "C" section
commit 7267e2b50d6752661c6cb42f7368b6b689c4ba04
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:42:20 2017 +0100

    New loplugin:externvar: libreofficekit
    
    Change-Id: Ib2a19249e1dd8d187b1fdc5559a9b4b9c2825e8c

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 0721080..0b8fa7d 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -46,7 +46,7 @@
 #define MIN_ZOOM 0.25f
 
 /// This is expected to be locked during setView(), doSomethingElse() LOK calls.
-std::mutex g_aLOKMutex;
+static std::mutex g_aLOKMutex;
 
 /// Same as a GdkRectangle, but also tracks in which part the rectangle is.
 struct ViewRectangle
commit 0cca099cfb5a653043867bc090eeec9f278d5749
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:42:11 2017 +0100

    New loplugin:externvar: linguistic
    
    Change-Id: I2fd1b1a6008067b8a289e1dc0ebfe7dfeb879328

diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx
index 79bb649..d50597a 100644
--- a/linguistic/source/lngopt.cxx
+++ b/linguistic/source/lngopt.cxx
@@ -91,7 +91,7 @@ struct WID_Name
 
 //! order of entries is import (see LinguOptions::GetName)
 //! since the WID is used as index in this table!
-WID_Name aWID_Name[] =
+WID_Name const aWID_Name[] =
 {
     { 0,                                  nullptr },
     { UPH_IS_USE_DICTIONARY_LIST,         UPN_IS_USE_DICTIONARY_LIST },
commit b63fbe006f74df9e1af2cec4271721972bb6de6b
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:42:00 2017 +0100

    New loplugin:externvar: odk
    
    Change-Id: I1f60c6b606a1ac96acbfa0777797acdaaea38c3c

diff --git a/odk/source/unoapploader/unx/unoapploader.c b/odk/source/unoapploader/unx/unoapploader.c
index e2b7b0b..e8c9a07 100644
--- a/odk/source/unoapploader/unx/unoapploader.c
+++ b/odk/source/unoapploader/unx/unoapploader.c
@@ -35,8 +35,8 @@
 char const* getPath(void);
 char* createCommandName( char* argv0 );
 
-const int SEPARATOR = '/';
-const char* PATHSEPARATOR = ":";
+static const int SEPARATOR = '/';
+static const char* PATHSEPARATOR = ":";
 
 
 /*
commit 089f89ef1030cdcf5dae2f9e8dc35b092eeecd9c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:41:44 2017 +0100

    New loplugin:externvar: pyuno
    
    Change-Id: Ib6822bf914fe44e8bd590dfe82d25d7c5046ca94

diff --git a/pyuno/source/module/pyuno_gc.cxx b/pyuno/source/module/pyuno_gc.cxx
index 8293b68..4520303 100644
--- a/pyuno/source/module/pyuno_gc.cxx
+++ b/pyuno/source/module/pyuno_gc.cxx
@@ -27,7 +27,7 @@
 namespace pyuno
 {
 
-bool g_destructorsOfStaticObjectsHaveBeenCalled;
+static bool g_destructorsOfStaticObjectsHaveBeenCalled;
 class StaticDestructorGuard
 {
 public:
@@ -36,7 +36,7 @@ public:
         g_destructorsOfStaticObjectsHaveBeenCalled = true;
     }
 };
-StaticDestructorGuard guard;
+static StaticDestructorGuard guard;
 
 static bool isAfterUnloadOrPy_Finalize()
 {
commit 953e0df86a7c9ae6ec6cedc20212dbd0b2a6e43f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:41:38 2017 +0100

    New loplugin:externvar: rsc
    
    Change-Id: Ifa9ead1325fdced36f189c5d5dcfd0e6d0ed63dd

diff --git a/rsc/source/parser/rsclex.cxx b/rsc/source/parser/rsclex.cxx
index 5d6040e..0725d8d 100644
--- a/rsc/source/parser/rsclex.cxx
+++ b/rsc/source/parser/rsclex.cxx
@@ -49,8 +49,8 @@ const char* StringContainer::putString( const char* pString )
     return aInsert.first->getStr();
 }
 
-int             c;
-bool            bLastInclude;//  true, if last symbol was INCLUDE
+static int      c;
+static bool     bLastInclude;//  true, if last symbol was INCLUDE
 RscFileInst*    pFI;
 RscTypCont*     pTC;
 RscExpression * pExp;
@@ -58,8 +58,9 @@ struct KeyVal
 {
     int     nKeyWord;
     YYSTYPE aYYSType;
-} aKeyVal[ 1 ];
-bool bTargetDefined;
+};
+static KeyVal aKeyVal[ 1 ];
+static bool bTargetDefined;
 
 StringContainer* pStringContainer = nullptr;
 
diff --git a/rsc/source/parser/rscyacc.y b/rsc/source/parser/rscyacc.y
index c0fd67d..b3bdf56 100644
--- a/rsc/source/parser/rscyacc.y
+++ b/rsc/source/parser/rscyacc.y
@@ -39,8 +39,8 @@
 #include <rsclex.hxx>
 
 ObjectStack                     S;
-RscTop *                        pCurClass;
-char                            szErrBuf[ 100 ];
+static RscTop *                 pCurClass;
+static char                     szErrBuf[ 100 ];
 
 RSCINST GetVarInst( const RSCINST & rInst, const char * pVarName )
 {
commit 387a035d749ff7f00beca82f83e7aa5d8c5e9fcd
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:41:25 2017 +0100

    New loplugin:externvar: sal
    
    Change-Id: Iefc33784f21e7a0b88c8d6308618926e38ab8554

diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx
index 8c9148b..7cf4123 100644
--- a/include/rtl/strbuf.hxx
+++ b/include/rtl/strbuf.hxx
@@ -34,6 +34,11 @@
 #include <rtl/stringconcat.hxx>
 #endif
 
+#ifdef RTL_STRING_UNITTEST
+extern bool rtl_string_unittest_const_literal;
+extern bool rtl_string_unittest_const_literal_function;
+#endif
+
 // The unittest uses slightly different code to help check that the proper
 // calls are made. The class is put into a different namespace to make
 // sure the compiler generates a different (if generating also non-inline)
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 827ab8e..8f5d044 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -39,6 +39,11 @@
 
 #include <sal/log.hxx>
 
+#ifdef RTL_STRING_UNITTEST
+extern bool rtl_string_unittest_const_literal;
+extern bool rtl_string_unittest_const_literal_function;
+#endif
+
 // The unittest uses slightly different code to help check that the proper
 // calls are made. The class is put into a different namespace to make
 // sure the compiler generates a different (if generating also non-inline)
diff --git a/include/rtl/stringconcat.hxx b/include/rtl/stringconcat.hxx
index d5bc4e8..9fd5332 100644
--- a/include/rtl/stringconcat.hxx
+++ b/include/rtl/stringconcat.hxx
@@ -17,6 +17,10 @@
 
 #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
 
+#if defined RTL_STRING_UNITTEST_CONCAT
+extern bool rtl_string_unittest_invalid_concat;
+#endif
+
 #ifdef RTL_STRING_UNITTEST
 #define rtl rtlunittest
 #endif
diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx
index 4665d20..57c73a8 100644
--- a/include/rtl/ustrbuf.hxx
+++ b/include/rtl/ustrbuf.hxx
@@ -35,6 +35,10 @@
 #include <rtl/stringconcat.hxx>
 #endif
 
+#ifdef RTL_STRING_UNITTEST
+extern bool rtl_string_unittest_invalid_conversion;
+#endif
+
 // The unittest uses slightly different code to help check that the proper
 // calls are made. The class is put into a different namespace to make
 // sure the compiler generates a different (if generating also non-inline)
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index c6c3124..eed067c 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -39,6 +39,10 @@
 #include <rtl/stringconcat.hxx>
 #endif
 
+#ifdef RTL_STRING_UNITTEST
+extern bool rtl_string_unittest_invalid_conversion;
+#endif
+
 // The unittest uses slightly different code to help check that the proper
 // calls are made. The class is put into a different namespace to make
 // sure the compiler generates a different (if generating also non-inline)
diff --git a/sal/inc/salusesyslog.hxx b/sal/inc/salusesyslog.hxx
new file mode 100644
index 0000000..ae1c14a
--- /dev/null
+++ b/sal/inc/salusesyslog.hxx
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SAL_INC_SALUSESYSLOG_HXX
+#define INCLUDED_SAL_INC_SALUSESYSLOG_HXX
+
+#include <sal/config.h>
+
+#include <config_global.h>
+
+#if HAVE_SYSLOG_H
+extern bool sal_use_syslog;
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index b400e43..23f45cd 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -27,6 +27,7 @@
 #include "sal/log.hxx"
 #include "sal/types.h"
 #include "misc.hxx"
+#include "salusesyslog.hxx"
 
 #if defined ANDROID
 #include <android/log.h>
diff --git a/sal/osl/unx/salinit.cxx b/sal/osl/unx/salinit.cxx
index da7ede5..fdde9e8 100644
--- a/sal/osl/unx/salinit.cxx
+++ b/sal/osl/unx/salinit.cxx
@@ -33,12 +33,11 @@
 #include "sal/types.h"
 
 #include <saltime.hxx>
+#include <salusesyslog.hxx>
 
 #if HAVE_SYSLOG_H
 #include <string.h>
 #include <syslog.h>
-// from sal/osl/all/log.cxx:
-extern bool sal_use_syslog;
 #endif
 
 extern "C" {
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 1f8841c..ae4243b 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -5090,6 +5090,6 @@ class GlobalObject
     }
 };
 
-GlobalObject theGlobalObject;
+static GlobalObject theGlobalObject;
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx
index 0326df1..b2adc17 100644
--- a/sal/qa/rtl/strings/test_ostring_concat.cxx
+++ b/sal/qa/rtl/strings/test_ostring_concat.cxx
@@ -9,7 +9,6 @@
 
 // activate support for detecting errors instead of getting compile errors
 #define RTL_STRING_UNITTEST_CONCAT
-bool rtl_string_unittest_invalid_concat = false;
 
 #include <sal/types.h>
 #include <cppunit/TestFixture.h>
@@ -22,6 +21,8 @@ bool rtl_string_unittest_invalid_concat = false;
 
 #include <typeinfo>
 
+bool rtl_string_unittest_invalid_concat = false;
+
 using namespace rtl;
 
 namespace std
diff --git a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
index 2b08581..9d81a90 100644
--- a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
@@ -9,10 +9,6 @@
 
 // activate the extra needed ctor
 #define RTL_STRING_UNITTEST
-bool rtl_string_unittest_const_literal;
-bool rtl_string_unittest_invalid_conversion;
-bool rtl_string_unittest_const_literal_function;
-bool rtl_string_unittest_non_const_literal_function;
 
 #include <sal/types.h>
 #include <cppunit/TestFixture.h>
@@ -21,6 +17,10 @@ bool rtl_string_unittest_non_const_literal_function;
 #include "rtl/string.hxx"
 #include "rtl/strbuf.hxx"
 
+bool rtl_string_unittest_const_literal;
+bool rtl_string_unittest_const_literal_function;
+static bool rtl_string_unittest_non_const_literal_function;
+
 namespace test { namespace ostring {
 
 class StringLiterals: public CppUnit::TestFixture
diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
index 3c0b996..094a779 100644
--- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx
@@ -9,10 +9,6 @@
 
 // activate the extra needed ctor
 #define RTL_STRING_UNITTEST
-extern bool rtl_string_unittest_const_literal;
-extern bool rtl_string_unittest_invalid_conversion;
-extern bool rtl_string_unittest_const_literal_function;
-extern bool rtl_string_unittest_non_const_literal_function;
 
 #include <sal/config.h>
 
@@ -26,6 +22,9 @@ extern bool rtl_string_unittest_non_const_literal_function;
 #include "rtl/ustring.hxx"
 #include "rtl/ustrbuf.hxx"
 
+extern bool rtl_string_unittest_const_literal;
+bool rtl_string_unittest_invalid_conversion;
+
 namespace test { namespace oustring {
 
 class StringLiterals: public CppUnit::TestFixture
commit 2f3bc785e675b40003b06f549a00775322f0b7fd
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:41:13 2017 +0100

    New loplugin:externvar: sc
    
    Change-Id: I6f9df997a957a1fa49161add2adafe228d036a30

diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 65b9eba..fa31f6f 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -216,6 +216,8 @@ protected:
     virtual css::uno::Reference< css::uno::XInterface > createUnoModel() override;
 };
 
+extern bool bDrawIsInUndo; // somewhere as member!
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index c6bbb83..e7bb936 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -31,6 +31,7 @@
 
 class Bitmap;
 class SfxItemSet;
+class SfxViewShell;
 class Color;
 struct ScCalcConfig;
 enum class SvtScriptType;
@@ -897,6 +898,10 @@ struct ScConsolidateParam
     void                SetAreas        ( ScArea* const* ppAreas, sal_uInt16 nCount );
 };
 
+extern SfxViewShell* pScActiveViewShell;
+extern sal_uInt16 nScClickMouseModifier;
+extern sal_uInt16 nScFillModeMouseModifier;
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index f736aa0..dd33288 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -65,8 +65,6 @@
 
 using ::com::sun::star::i18n::LocaleDataItem;
 
-// Err527 Workaround
-extern const ScFormulaCell* pLastFormulaTreeTop; // in cellform.cxx
 using namespace formula;
 
 void ScColumn::Broadcast( SCROW nRow )
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index 9ea2a2e..282e1a53 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -41,8 +41,6 @@
 
 #include "globstr.hrc"
 
-extern const ScFormulaCell* pLastFormulaTreeTop;    // cellform.cxx Err527 WorkAround
-
 void ScDocument::StartListeningArea(
     const ScRange& rRange, bool bGroupListening, SvtListener* pListener )
 {
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 81cfd9c..aa7e442 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -68,8 +68,6 @@
 
 #define D_MAX_LONG_  (double) 0x7fffffff
 
-extern sal_uInt16 nScFillModeMouseModifier;     // global.cxx
-
 namespace {
 
 short lcl_DecompValueString( OUString& rValue, sal_Int32& nVal, sal_uInt16* pMinDigits = nullptr )
diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx
index 4552389..6d48398 100644
--- a/sc/source/core/tool/autoform.cxx
+++ b/sc/source/core/tool/autoform.cxx
@@ -41,8 +41,6 @@
  * be synchronized with Writer's SwTableAutoFmtTbl sw/source/core/doc/tblafmt.cxx
  */
 
-const sal_Char *linker_dummy = "";
-
 static const sal_Char sAutoTblFmtName[] = "autotbl.fmt";
 
 // till SO5PF
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index dab0d2d..06019ea 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -30,9 +30,6 @@
 #include "sc.hrc"
 #include <editutil.hxx>
 
-// Err527 Workaround
-const ScFormulaCell* pLastFormulaTreeTop = nullptr;
-
 void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString,
                               Color** ppColor, SvNumberFormatter& rFormatter, const ScDocument* pDoc,
                               bool bNullVals, bool bFormula, bool bUseStarFormat )
diff --git a/sc/source/filter/xml/editattributemap.cxx b/sc/source/filter/xml/editattributemap.cxx
index 3a2dec7..fdb009c 100644
--- a/sc/source/filter/xml/editattributemap.cxx
+++ b/sc/source/filter/xml/editattributemap.cxx
@@ -13,7 +13,7 @@
 #include <editeng/memberids.hrc>
 #include <xmloff/xmlnmspe.hxx>
 
-ScXMLEditAttributeMap::Entry aEntries[] = {
+ScXMLEditAttributeMap::Entry const aEntries[] = {
 
     { XML_NAMESPACE_FO, "color", "CharColor", EE_CHAR_COLOR, 0 },
     { XML_NAMESPACE_STYLE, "font-charset", "CharFontCharSet", EE_CHAR_FONTINFO, MID_FONT_CHAR_SET },
diff --git a/sc/source/ui/inc/drawview.hxx b/sc/source/ui/inc/drawview.hxx
index 7fd1735..7111ddf 100644
--- a/sc/source/ui/inc/drawview.hxx
+++ b/sc/source/ui/inc/drawview.hxx
@@ -158,6 +158,8 @@ public:
     SfxViewShell* GetSfxViewShell() const override;
 };
 
+extern Point aDragStartDiff;
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 30f4026..59f7af2 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -353,6 +353,9 @@ private:
                                        SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount );
 };
 
+extern bool bPasteIsDrop;
+extern bool bPasteIsMove;
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 5ace37e..9aee173 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -51,8 +51,6 @@
 #include <utility>
 #include <vector>
 
-extern bool bDrawIsInUndo; // somewhere as member!
-
 using namespace com::sun::star;
 using ::std::unique_ptr;
 using ::std::vector;
diff --git a/sc/source/ui/unoobj/targuno.cxx b/sc/source/ui/unoobj/targuno.cxx
index 3180a13..8a270a2 100644
--- a/sc/source/ui/unoobj/targuno.cxx
+++ b/sc/source/ui/unoobj/targuno.cxx
@@ -39,7 +39,7 @@
 
 using  namespace ::com::sun::star;
 
-sal_uInt16 nTypeResIds[SC_LINKTARGETTYPE_COUNT] =
+sal_uInt16 const nTypeResIds[SC_LINKTARGETTYPE_COUNT] =
 {
     SCSTR_CONTENT_TABLE,        // SC_LINKTARGETTYPE_SHEET
     SCSTR_CONTENT_RANGENAME,    // SC_LINKTARGETTYPE_RANGENAME
diff --git a/sc/source/ui/vba/service.cxx b/sc/source/ui/vba/service.cxx
index 9c52d09..1a27ae7 100644
--- a/sc/source/ui/vba/service.cxx
+++ b/sc/source/ui/vba/service.cxx
@@ -19,6 +19,8 @@
 #include <cppuhelper/implementationentry.hxx>
 #include <comphelper/servicedecl.hxx>
 
+#include <service.hxx>
+
 // component exports
 
 using namespace ::com::sun::star;
@@ -26,32 +28,6 @@ using namespace ::com::sun::star::uno;
 
 namespace sdecl = comphelper::service_decl;
 
-// reference service helper(s)
-namespace  range
-{
-extern sdecl::ServiceDecl const serviceDecl;
-}
-namespace  workbook
-{
-extern sdecl::ServiceDecl const serviceDecl;
-}
-namespace  worksheet
-{
-extern sdecl::ServiceDecl const serviceDecl;
-}
-namespace window
-{
-extern sdecl::ServiceDecl const serviceDecl;
-}
-namespace hyperlink
-{
-extern sdecl::ServiceDecl const serviceDecl;
-}
-namespace application
-{
-extern sdecl::ServiceDecl const serviceDecl;
-}
-
 extern "C"
 {
     SAL_DLLPUBLIC_EXPORT void * SAL_CALL vbaobj_component_getFactory(
diff --git a/sc/source/ui/vba/service.hxx b/sc/source/ui/vba/service.hxx
new file mode 100644
index 0000000..5735551
--- /dev/null
+++ b/sc/source/ui/vba/service.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SC_SOURCE_UI_VBA_SERVICE_HXX
+#define INCLUDED_SC_SOURCE_UI_VBA_SERVICE_HXX
+
+#include <sal/config.h>
+
+namespace comphelper { namespace service_decl { class ServiceDecl; } }
+
+namespace application {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace hyperlink {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace range {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace window {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace workbook {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+namespace worksheet {
+extern comphelper::service_decl::ServiceDecl const serviceDecl;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index 146ef3a..c9d55cd 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -35,6 +35,7 @@
 #include <ooo/vba/excel/XlMousePointer.hpp>
 #include <ooo/vba/office/MsoShapeType.hpp>
 
+#include "service.hxx"
 #include "vbaapplication.hxx"
 #include "vbaworkbooks.hxx"
 #include "vbaworkbook.hxx"
@@ -1334,8 +1335,8 @@ ScVbaApplication::getServiceNames()
 namespace application
 {
 namespace sdecl = comphelper::service_decl;
-sdecl::vba_service_class_<ScVbaApplication, sdecl::with_args<false> > serviceImpl;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::vba_service_class_<ScVbaApplication, sdecl::with_args<false> > const serviceImpl;
+sdecl::ServiceDecl const serviceDecl(
     serviceImpl,
     "ScVbaApplication",
     "ooo.vba.excel.Application" );
diff --git a/sc/source/ui/vba/vbahyperlink.cxx b/sc/source/ui/vba/vbahyperlink.cxx
index 0958fef..d9451e3 100644
--- a/sc/source/ui/vba/vbahyperlink.cxx
+++ b/sc/source/ui/vba/vbahyperlink.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include "service.hxx"
 #include "vbahyperlink.hxx"
 #include <vbahelper/helperdecl.hxx>
 #include <com/sun/star/container/XIndexAccess.hpp>
@@ -224,8 +227,8 @@ void ScVbaHyperlink::setUrlComponents( const UrlComponents& rUrlComp ) throw (un
 namespace hyperlink
 {
 namespace sdecl = comphelper::service_decl;
-sdecl::vba_service_class_<ScVbaHyperlink, sdecl::with_args<true> > serviceImpl;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::vba_service_class_<ScVbaHyperlink, sdecl::with_args<true> > const serviceImpl;
+sdecl::ServiceDecl const serviceDecl(
     serviceImpl,
     "ScVbaHyperlink",
     "ooo.vba.excel.Hyperlink" );
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 54b5891..fe1247d 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -135,6 +135,7 @@
 #include <globstr.hrc>
 #include <unonames.hxx>
 
+#include "service.hxx"
 #include "vbaapplication.hxx"
 #include "vbafont.hxx"
 #include "vbacomment.hxx"
@@ -5589,8 +5590,8 @@ ScVbaRange::hasError() throw (uno::RuntimeException, std::exception)
 namespace range
 {
 namespace sdecl = comphelper::service_decl;
-sdecl::vba_service_class_<ScVbaRange, sdecl::with_args<true> > serviceImpl;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::vba_service_class_<ScVbaRange, sdecl::with_args<true> > const serviceImpl;
+sdecl::ServiceDecl const serviceDecl(
     serviceImpl,
     "SvVbaRange",
     "ooo.vba.excel.Range" );
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx
index de36e6d..985dfc8 100644
--- a/sc/source/ui/vba/vbawindow.cxx
+++ b/sc/source/ui/vba/vbawindow.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 #include <vbahelper/helperdecl.hxx>
+#include "service.hxx"
 #include "vbawindow.hxx"
 #include "vbaworksheets.hxx"
 #include "vbaworksheet.hxx"
@@ -898,8 +899,8 @@ ScVbaWindow::getServiceNames()
 namespace window
 {
 namespace sdecl = comphelper::service_decl;
-sdecl::vba_service_class_<ScVbaWindow, sdecl::with_args<true> > serviceImpl;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::vba_service_class_<ScVbaWindow, sdecl::with_args<true> > const serviceImpl;
+sdecl::ServiceDecl const serviceDecl(
     serviceImpl,
     "ScVbaWindow",
     "ooo.vba.excel.Window" );
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index d7a0e6a..a732f0f 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -34,6 +34,7 @@
 #include <ooo/vba/excel/XApplication.hpp>
 
 #include "scextopt.hxx"
+#include "service.hxx"
 #include "vbaworksheet.hxx"
 #include "vbaworksheets.hxx"
 #include "vbaworkbook.hxx"
@@ -416,8 +417,8 @@ ScVbaWorkbook::getSomething(const uno::Sequence<sal_Int8 >& rId ) throw(css::uno
 namespace workbook
 {
 namespace sdecl = comphelper::service_decl;
-sdecl::vba_service_class_<ScVbaWorkbook, sdecl::with_args<true> > serviceImpl;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::vba_service_class_<ScVbaWorkbook, sdecl::with_args<true> > const serviceImpl;
+sdecl::ServiceDecl const serviceDecl(
     serviceImpl,
     "ScVbaWorkbook",
     "ooo.vba.excel.Workbook" );
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index 7aaec25..ff021a8 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -84,6 +84,7 @@
 #include "drwlayer.hxx"
 #include "tabprotection.hxx"
 #include "scextopt.hxx"
+#include "service.hxx"
 #include "vbaoutline.hxx"
 #include "vbarange.hxx"
 #include "vbacomments.hxx"
@@ -1098,8 +1099,8 @@ ScVbaWorksheet::getSomething(const uno::Sequence<sal_Int8 > & rId) throw(uno::Ru
 namespace worksheet
 {
 namespace sdecl = comphelper::service_decl;
-sdecl::vba_service_class_<ScVbaWorksheet, sdecl::with_args<true> > serviceImpl;
-extern sdecl::ServiceDecl const serviceDecl(
+sdecl::vba_service_class_<ScVbaWorksheet, sdecl::with_args<true> > const serviceImpl;
+sdecl::ServiceDecl const serviceDecl(
     serviceImpl,
     "ScVbaWorksheet",
     "ooo.vba.excel.Worksheet" );
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index edd5d24..578fd2a 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -162,10 +162,6 @@ enum ScFilterBoxMode
     SC_FILTERBOX_PAGEFIELD
 };
 
-extern SfxViewShell* pScActiveViewShell;    // global.cxx
-extern sal_uInt16 nScClickMouseModifier;    // global.cxx
-extern sal_uInt16 nScFillModeMouseModifier; // global.cxx
-
 struct ScGridWindow::MouseEventState
 {
     bool mbActivatePart;
@@ -3505,9 +3501,6 @@ static ScRange lcl_MakeDropRange( SCCOL nPosX, SCROW nPosY, SCTAB nTab, const Sc
     return ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
 }
 
-extern bool bPasteIsDrop;       // viewfun4 -> move to header
-extern bool bPasteIsMove;       // viewfun7 -> move to header
-
 sal_Int8 ScGridWindow::AcceptPrivateDrop( const AcceptDropEvent& rEvt )
 {
     if ( rEvt.mbLeaving )
diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx
index 8f1f92d..714b991 100644
--- a/sc/source/ui/view/select.cxx
+++ b/sc/source/ui/view/select.cxx
@@ -36,8 +36,6 @@
 #define SC_SELENG_REFMODE_UPDATE_INTERVAL_MIN 65
 #endif
 
-extern sal_uInt16 nScFillModeMouseModifier;             // global.cxx
-
 using namespace com::sun::star;
 
 static Point aSwitchPos;                //! Member
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index fdc633d..3196b29 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -29,8 +29,6 @@
 #include "formulacell.hxx"
 #include "dociter.hxx"
 
-extern sal_uInt16 nScFillModeMouseModifier;             // global.cxx
-
 // ---  Referenz-Eingabe / Fill-Cursor
 
 void ScTabView::HideTip()
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index de54fd3..5425f76 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -102,8 +102,6 @@
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <comphelper/lok.hxx>
 
-extern SfxViewShell* pScActiveViewShell;            // global.cxx
-
 using namespace com::sun::star;
 
 void ScTabViewShell::Activate(bool bMDI)
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index 9f9fe22..af59f93 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -49,8 +49,6 @@
 #include "dragdata.hxx"
 #include <gridwin.hxx>
 
-extern Point aDragStartDiff;
-
 bool bPasteIsMove = false;
 
 using namespace com::sun::star;
commit e88309519accfbde8f19d1ce36b657707683bb61
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jan 9 15:41:09 2017 +0100

    New loplugin:externvar: scripting
    
    Change-Id: I79b4e8718c10b5c5fce9f734a5a30ce9bc01e0c7

diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx
index 44fea79..b7fc4b5 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -174,8 +174,8 @@ struct TranslateInfo
 {
     OUString sVBAName; //vba event name
     Translator toVBA;       //the method to convert OO event parameters to VBA event parameters
-    bool (*ApproveRule)(const ScriptEvent& evt, void* pPara); //this method is used to determine which types of controls should execute the event
-    void *pPara;            //Parameters for the above approve method
+    bool (*ApproveRule)(const ScriptEvent& evt, void const * pPara); //this method is used to determine which types of controls should execute the event
+    void const *pPara;            //Parameters for the above approve method
 };
 
 
@@ -191,41 +191,41 @@ struct TranslatePropMap
     TranslateInfo aTransInfo;
 };
 
-bool ApproveAll(const ScriptEvent& evt, void* pPara); //allow all types of controls to execute the event
-bool ApproveType(const ScriptEvent& evt, void* pPara); //certain types of controls should execute the event, those types are given by pPara
-bool DenyType(const ScriptEvent& evt, void* pPara);    //certain types of controls should not execute the event, those types are given by pPara
-bool DenyMouseDrag(const ScriptEvent& evt, void* pPara); //used for VBA MouseMove event when "Shift" key is pressed
+bool ApproveAll(const ScriptEvent& evt, void const * pPara); //allow all types of controls to execute the event
+bool ApproveType(const ScriptEvent& evt, void const * pPara); //certain types of controls should execute the event, those types are given by pPara
+bool DenyType(const ScriptEvent& evt, void const * pPara);    //certain types of controls should not execute the event, those types are given by pPara

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list