compilerplugins/clang/check.cxx | 11 ++------ compilerplugins/clang/test/unusedvariablecheck.cxx | 28 +++++++++++++++++++++ configure.ac | 2 + 3 files changed, 33 insertions(+), 8 deletions(-)
New commits: commit 657ead3c4d8770117067d5b05a3bdd6dddb75a8b Author: Stephan Bergmann <sberg...@redhat.com> Date: Wed Nov 8 15:27:43 2017 +0100 Add comment to eventually remove HAVE_GCC_ATTRIBUTE_WARN_UNUSED Change-Id: I71da6641768f804b19e16c899232f33efd4a9ae9 diff --git a/configure.ac b/configure.ac index fdd9c005fc1a..26cfb628e3e6 100644 --- a/configure.ac +++ b/configure.ac @@ -5904,6 +5904,8 @@ if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then ], [AC_MSG_RESULT([no])]) AC_LANG_POP([C++]) + dnl Available in GCC 4.9 and at least in Clang 3.4 (which is the baseline + dnl for at least --enable-compiler-plugins according to README.md): AC_MSG_CHECKING([whether $CXX supports __attribute__((warn_unused))]) AC_LANG_PUSH([C++]) save_CXXFLAGS=$CXXFLAGS commit 871e420cbbd8afe064e7bbc0ed426db3b01fddfa Author: Stephan Bergmann <sberg...@redhat.com> Date: Wed Nov 8 15:23:24 2017 +0100 Fix loplugin::unusedvariablecheck check for std classes (but which finds no new hits) Change-Id: I862a3c82932ee6d6d0946cd33f965bb8e917cff8 diff --git a/compilerplugins/clang/check.cxx b/compilerplugins/clang/check.cxx index 03d9683a4903..6f9ee1779bf6 100644 --- a/compilerplugins/clang/check.cxx +++ b/compilerplugins/clang/check.cxx @@ -216,14 +216,9 @@ bool isExtraWarnUnusedType(clang::QualType type) { } auto const tc = TypeCheck(rec); // Check some common non-LO types: - if (tc.Class("string").Namespace("std").GlobalNamespace() - || tc.Class("basic_string").Namespace("std").GlobalNamespace() - || tc.Class("list").Namespace("std").GlobalNamespace() - || (tc.Class("list").Namespace("__debug").Namespace("std") - .GlobalNamespace()) - || tc.Class("vector").Namespace("std").GlobalNamespace() - || (tc.Class("vector" ).Namespace("__debug").Namespace("std") - .GlobalNamespace())) + if (tc.Class("basic_string").StdNamespace() + || tc.Class("list").StdNamespace() + || tc.Class("vector").StdNamespace()) { return true; } diff --git a/compilerplugins/clang/test/unusedvariablecheck.cxx b/compilerplugins/clang/test/unusedvariablecheck.cxx new file mode 100644 index 000000000000..c5b2a04d89fe --- /dev/null +++ b/compilerplugins/clang/test/unusedvariablecheck.cxx @@ -0,0 +1,28 @@ +/* -*- 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 <sal/config.h> + +#include <list> +#include <string> +#include <vector> + +namespace +{ +template <typename T> using Vec = std::vector<T>; +} + +int main() +{ + std::list<int> v1; // expected-error {{unused variable 'v1' [loplugin:unusedvariablecheck]}} + std::string v2; // expected-error {{unused variable 'v2' [loplugin:unusedvariablecheck]}} + Vec<int> v3; // expected-error {{unused variable 'v3' [loplugin:unusedvariablecheck]}} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits