Hello,The following fixes are needed with g++ 11 in branch. They are not needed in master, where clang 10 already made them visible.
OK to commit? JMarc
From 3beb9b326d4bd29e4122d759ef48f32a7488161d Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Fri, 15 Oct 2021 15:49:40 +0200 Subject: [PATCH 1/6] Remove variable that is not used Spotted by clang++ 13. (cherry picked from commit d99502d9154e7e51a665f03963e010411e9545be) --- src/frontends/qt4/GuiDocument.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 41b08fce7e..b20e16a771 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -2745,10 +2745,7 @@ void GuiDocument::updateEngineType(string const & items, CiteEngineType const & { engine_types_.clear(); - int nn = 0; - for (int n = 0; !token(items, '|', n).empty(); ++n) { - nn += 1; string style = token(items, '|', n); engine_types_.push_back(style); } -- 2.32.0
From 4d410d0d32a6ade8e5ee27f4390a0340ed8d5b60 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Tue, 28 Apr 2020 13:27:50 +0200 Subject: [PATCH 2/6] Do not for copies in range-based for loops. Spotted by clang++ 10. (cherry picked from commit a85c48de5a15c4f70f79a53b451fbe0d083e9ece) --- src/HunspellChecker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HunspellChecker.cpp b/src/HunspellChecker.cpp index 593a123bf9..c211b47c85 100644 --- a/src/HunspellChecker.cpp +++ b/src/HunspellChecker.cpp @@ -424,7 +424,7 @@ void HunspellChecker::suggest(WordLangTuple const & wl, string const word_to_check = to_iconv_encoding(wl.word(), encoding); #ifdef HAVE_HUNSPELL_CXXABI vector<string> wlst = h->suggest(word_to_check); - for (auto const s : wlst) + for (auto const & s : wlst) suggestions.push_back(remap_result(from_iconv_encoding(s, encoding))); #else char ** suggestion_list; @@ -449,7 +449,7 @@ void HunspellChecker::stem(WordLangTuple const & wl, string const word_to_check = to_iconv_encoding(wl.word(), encoding); #ifdef HAVE_HUNSPELL_CXXABI vector<string> wlst = h->stem(word_to_check); - for (auto const s : wlst) + for (auto const & s : wlst) suggestions.push_back(from_iconv_encoding(s, encoding)); #else char ** suggestion_list; -- 2.32.0
From cca4b8d42a282d3b93d86acb0e990074db4f7fd3 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Fri, 15 Oct 2021 16:10:04 +0200 Subject: [PATCH 3/6] Avoid some more copies in range-based for loops This triggers warnings with clang++ 10 and gcc 11. (cherry-picked from commit 7035e230caa69a2e35f16dcf0d9696c59cef5c4c) --- src/frontends/qt4/Menus.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index 5f9eb9068d..a2505dc250 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -1337,7 +1337,7 @@ void MenuDefinition::expandToc(Buffer const * buf) // In the navigation menu, only add tocs from this document TocBackend const & backend = buf->tocBackend(); TocList const & toc_list = backend.tocs(); - for (pair<string, shared_ptr<Toc>> const & toc : toc_list) { + for (pair<const string, shared_ptr<Toc>> const & toc : toc_list) { // Handle table of contents later if (toc.first == "tableofcontents" || toc.second->empty()) continue; @@ -1695,7 +1695,7 @@ void MenuDefinition::expandCaptions(Buffer const * buf, bool switchcap) DocumentClass const & dc = buf->params().documentClass(); vector< pair<docstring, FuncRequest> > caps; - for (pair<docstring, InsetLayout> const & il : dc.insetLayouts()) { + for (pair<const docstring, InsetLayout> const & il : dc.insetLayouts()) { docstring instype; docstring const type = split(il.first, instype, ':'); if (instype == from_ascii("Caption")) { -- 2.32.0
From 09b340a45e4563d11a9a132c86693fb44f898b81 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Fri, 15 Oct 2021 17:41:01 +0200 Subject: [PATCH 4/6] Fix more unintended copies in range-based for loops Spotted by g++ 11. --- src/Encoding.cpp | 2 +- src/TocBackend.cpp | 2 +- src/frontends/qt4/TocModel.cpp | 2 +- src/insets/InsetInclude.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Encoding.cpp b/src/Encoding.cpp index 35a93b40ec..d0046ecc06 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -267,7 +267,7 @@ vector<char_type> Encoding::symbolsList() const // add all encodable characters copy(encodable_.begin(), encodable_.end(), back_inserter(symbols)); // now the ones from the unicodesymbols file that are not already there - for (pair<char_type, CharInfo> const & elem : unicodesymbols) { + for (pair<const char_type, CharInfo> const & elem : unicodesymbols) { if (find(symbols.begin(), symbols.end(), elem.first) == symbols.end()) symbols.push_back(elem.first); } diff --git a/src/TocBackend.cpp b/src/TocBackend.cpp index a253d57ca3..4bb91816e8 100644 --- a/src/TocBackend.cpp +++ b/src/TocBackend.cpp @@ -272,7 +272,7 @@ void TocBackend::resetOutlinerNames() { outliner_names_.clear(); // names from this document class - for (pair<string, docstring> const & name + for (pair<const string, docstring> const & name : buffer_->params().documentClass().outlinerNames()) addName(name.first, translateIfPossible(name.second)); // Hardcoded types diff --git a/src/frontends/qt4/TocModel.cpp b/src/frontends/qt4/TocModel.cpp index 0733c1f641..a5b5bc5538 100644 --- a/src/frontends/qt4/TocModel.cpp +++ b/src/frontends/qt4/TocModel.cpp @@ -353,7 +353,7 @@ void TocModels::reset(BufferView const * bv) names_->insertColumns(0, 1); // In the outliner, add Tocs from the master document TocBackend const & backend = bv->buffer().masterBuffer()->tocBackend(); - for (pair<string, shared_ptr<Toc>> const & toc : backend.tocs()) { + for (pair<const string, shared_ptr<Toc>> const & toc : backend.tocs()) { QString const type = toqstr(toc.first); // First, fill in the toc models. diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 7bf2329814..dcfa73b08d 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -1288,7 +1288,7 @@ void InsetInclude::addToToc(DocIterator const & cpit, bool output_active, //Copy missing outliner names (though the user has been warned against //having different document class and module selection between master //and child). - for (pair<string, docstring> const & name + for (pair<const string, docstring> const & name : childbuffer->params().documentClass().outlinerNames()) backend.addName(name.first, translateIfPossible(name.second)); } -- 2.32.0
From dfa97f80d9fc1c8c6a4cd03234c4429fa95362a0 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Fri, 15 Oct 2021 16:20:40 +0200 Subject: [PATCH 5/6] Explicit InsetTableCell copy constructor Use explicit default syntax (C++11). Adapted from: commit bff97ba76d65da3f9048ef107b29ee642bdd5229 commit 3d46cc302bcff979a874ef2ea9c8a56a85aaec77 --- src/insets/InsetTabular.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 1398276a89..1e2fb655ad 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -53,6 +53,9 @@ class InsetTableCell : public InsetText public: /// InsetTableCell(Buffer * buf); + /// We need this since generation of the default is deprecated + /// (since we declare the assignment constuctor below). + InsetTableCell(InsetTableCell const & in) = default; /// InsetCode lyxCode() const { return CELL_CODE; } /// -- 2.32.0
From 497ca64574af9250d09db11b9c3774ff8f55e724 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Fri, 15 Oct 2021 17:05:04 +0200 Subject: [PATCH 6/6] Autoconf: disable warning deprecated-copy when supported Cherry-picked from: 4aee447af1ab29d094e917b94ec3e3d4af36f1cd c52049bb83d71b926e6b949362a47bde9f8d5653 37c34c5ca98a31669144a7119068edf96d68261c --- config/lyxinclude.m4 | 11 ++++---- m4/ax_check_compile_flag.m4 | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 m4/ax_check_compile_flag.m4 diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4 index 59421ae225..2443201a5d 100644 --- a/config/lyxinclude.m4 +++ b/config/lyxinclude.m4 @@ -411,11 +411,12 @@ if test x$GXX = xyes; then dnl Warnings are for preprocessor too if test x$enable_warnings = xyes ; then AM_CPPFLAGS="$AM_CPPFLAGS -Wall -Wextra" - case $gxx_version in - 9.*|10.*|clang-10*) - AM_CXXFLAGS="$AM_CXXFLAGS -Wno-deprecated-copy";; - *);; - esac + dnl Shut off warning -Wdeprecated-copy, which triggers too much + dnl note that g++ always accepts -Wno-xxx, even when -Wxxx is an error. + AC_LANG_PUSH(C++) + AX_CHECK_COMPILE_FLAG([-Wdeprecated-copy], + [AM_CXXFLAGS="$AM_CXXFLAGS -Wno-deprecated-copy"], [], [-Werror]) + AC_LANG_POP(C++) fi case $gxx_version in 2.*|3.*) AC_ERROR([gcc >= 4.6 is required]);; diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 0000000000..bd753b34d7 --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -0,0 +1,53 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim <gui...@gmx.de> +# Copyright (c) 2011 Maarten Bosmans <mkbosm...@gmail.com> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS -- 2.32.0
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel