From fa8cf9f65d7c18fcde4c43ebca971ddc1c4df30c Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Thu, 31 May 2018 08:41:07 +0200 Subject: [PATCH] Fix warnings in tests, clang-6 --- tests/base/aligned_vector_04.cc | 8 +++---- tests/base/table_06.cc | 8 +++---- tests/bits/accessor_equality.cc | 4 +++- tests/bits/distorted_cells_06.cc | 4 ++-- tests/codim_one/integrate_log.cc | 13 +++++------ tests/grid/intergrid_map.cc | 4 ++-- tests/lac/block_linear_operator_01.cc | 10 +++++---- tests/lac/pointer_matrix_03.cc | 2 +- tests/lac/pointer_matrix_04.cc | 2 +- tests/lac/pointer_matrix_05.cc | 6 ++++-- tests/lac/pointer_matrix_06.cc | 4 ++-- tests/lac/pointer_matrix_07.cc | 4 ++-- tests/lac/pointer_matrix_08.cc | 4 ++-- tests/lac/sparse_matrix_move.cc | 16 ++++---------- tests/lac/sparse_matrix_move.output | 1 + tests/manifold/chart_manifold_06.cc | 6 +++--- tests/numerics/project_boundary_01.cc | 4 ++-- tests/opencascade/manifold_clone_01.cc | 30 +++++++++++++++----------- 18 files changed, 68 insertions(+), 62 deletions(-) diff --git a/tests/base/aligned_vector_04.cc b/tests/base/aligned_vector_04.cc index 8523b8d021..a7f8b67ed3 100644 --- a/tests/base/aligned_vector_04.cc +++ b/tests/base/aligned_vector_04.cc @@ -31,14 +31,14 @@ class FunctionBase { public: - ~FunctionBase() + virtual ~FunctionBase() {} virtual void do_test() = 0; }; -class Function +class Function : public FunctionBase { public: Function() : size_(2) @@ -51,13 +51,13 @@ public: deallog << "Copy construct object" << std::endl; } - ~Function() + virtual ~Function() override { deallog << "Destruct with size " << vec.size() << std::endl; } virtual void - do_test() + do_test() override { vec.resize(size_++); deallog << "Resize vector to " << vec.size() << std::endl; diff --git a/tests/base/table_06.cc b/tests/base/table_06.cc index cb499f00aa..cff3568164 100644 --- a/tests/base/table_06.cc +++ b/tests/base/table_06.cc @@ -31,14 +31,14 @@ class FunctionBase { public: - ~FunctionBase() + virtual ~FunctionBase() {} virtual void do_test() = 0; }; -class Function +class Function : public FunctionBase { public: Function() : size_(2) @@ -51,13 +51,13 @@ public: deallog << "Copy construct object" << std::endl; } - ~Function() + virtual ~Function() override { deallog << "Destruct with size " << vec.size() << std::endl; } virtual void - do_test() + do_test() override { vec.resize(size_++); deallog << "Resize vector to " << vec.size() << std::endl; diff --git a/tests/bits/accessor_equality.cc b/tests/bits/accessor_equality.cc index b7ebc2bdba..e84cd808ed 100644 --- a/tests/bits/accessor_equality.cc +++ b/tests/bits/accessor_equality.cc @@ -92,7 +92,9 @@ test() dof_handler2.distribute_dofs(fe); try { - (dof_handler.begin_active() != dof_handler2.begin_active()); + bool is_same = + (dof_handler.begin_active() != dof_handler2.begin_active()); + (void)is_same; } catch (ExceptionBase &e) { diff --git a/tests/bits/distorted_cells_06.cc b/tests/bits/distorted_cells_06.cc index 05f94b292d..c33d9306aa 100644 --- a/tests/bits/distorted_cells_06.cc +++ b/tests/bits/distorted_cells_06.cc @@ -49,7 +49,7 @@ class MyManifold : public Manifold virtual Point get_new_point_on_line( - const typename Triangulation::line_iterator &line) const + const typename Triangulation::line_iterator &line) const override { deallog << "Finding point between " << line->vertex(0) << " and " << line->vertex(1) << std::endl; @@ -59,7 +59,7 @@ class MyManifold : public Manifold virtual Point get_new_point_on_quad( - const typename Triangulation::quad_iterator &) const + const typename Triangulation::quad_iterator &) const override { Assert(false, ExcInternalError()); return Point(0, 0, 1.25); diff --git a/tests/codim_one/integrate_log.cc b/tests/codim_one/integrate_log.cc index 6ff5d9ac6b..2832c50261 100644 --- a/tests/codim_one/integrate_log.cc +++ b/tests/codim_one/integrate_log.cc @@ -120,14 +120,15 @@ factorial(unsigned int a) double newton_binomial(unsigned int a, unsigned int b) { - double c; + double c = 0.; if (a >= b) - c = factorial(a) / factorial(b) / factorial(a - b); - else - deallog - << "Error: in Newton binomial the first integer must be greater or equal to the second."; + return factorial(a) / factorial(b) / factorial(a - b); - return c; + // we should not get here + deallog << "Error: in Newton binomial the first integer " + "must be greater or equal to the second."; + + return 0.; } int diff --git a/tests/grid/intergrid_map.cc b/tests/grid/intergrid_map.cc index b395c57666..7bacd751fe 100644 --- a/tests/grid/intergrid_map.cc +++ b/tests/grid/intergrid_map.cc @@ -14,8 +14,8 @@ // --------------------------------------------------------------------- /* -/* Author: Wolfgang Bangerth, University of Heidelberg, 2000 -/* + * Author: Wolfgang Bangerth, University of Heidelberg, 2000 + * * Purpose: check some things with the intergrid map */ diff --git a/tests/lac/block_linear_operator_01.cc b/tests/lac/block_linear_operator_01.cc index 6f8af8db8e..7d4f2f06e3 100644 --- a/tests/lac/block_linear_operator_01.cc +++ b/tests/lac/block_linear_operator_01.cc @@ -112,7 +112,7 @@ main() auto op_b11 = linear_operator(a.block(1, 1)); std::array, 2> temp{ - {op_b00, op_b01, op_b10, op_b11}}; + {{op_b00, op_b01}, {op_b10, op_b11}}}; auto op_b = block_operator<2, 2, BlockVector>(temp); { @@ -189,7 +189,9 @@ main() // And finally complicated block structures: std::array, 3> temp2{ - {op_b00, op_b01, op_b00, op_b10, op_b11, op_b10, op_b10, op_b11, op_b10}}; + {{op_b00, op_b01, op_b00}, + {op_b10, op_b11, op_b10}, + {op_b10, op_b11, op_b10}}}; auto op_upp_x_upu = block_operator<3, 3, BlockVector>(temp2); op_upp_x_upu.reinit_domain_vector(u, false); @@ -208,11 +210,11 @@ main() PRINTME("v", v); std::array, 3> temp3{ - {op_b01, op_b11, op_b11}}; + {{op_b01}, {op_b11}, {op_b11}}}; auto op_upp_x_p = block_operator<3, 1, BlockVector>(temp3); std::array, 1> temp4{ - {op_b00, op_b01, op_b00}}; + {{op_b00, op_b01, op_b00}}}; auto op_u_x_upu = block_operator<1, 3, BlockVector>(temp4); auto op_long = op_u_x_upu * transpose_operator(op_upp_x_upu) * op_upp_x_p; diff --git a/tests/lac/pointer_matrix_03.cc b/tests/lac/pointer_matrix_03.cc index d78e1ac73e..c34c8a23cd 100644 --- a/tests/lac/pointer_matrix_03.cc +++ b/tests/lac/pointer_matrix_03.cc @@ -38,7 +38,7 @@ main() deallog << std::setprecision(4); deallog.attach(logfile); - char *name = "Matrix A"; + char name[] = "Matrix A"; checkConstructor3(name); } diff --git a/tests/lac/pointer_matrix_04.cc b/tests/lac/pointer_matrix_04.cc index fc6a4650e7..d87f4a3a3b 100644 --- a/tests/lac/pointer_matrix_04.cc +++ b/tests/lac/pointer_matrix_04.cc @@ -43,7 +43,7 @@ main() FullMatrix A(2, 2); A.fill(Adata); - char *name = "Matrix A"; + char name[] = "Matrix A"; checkConstructor4(A, name); } diff --git a/tests/lac/pointer_matrix_05.cc b/tests/lac/pointer_matrix_05.cc index 358e6f1999..cbda10a1e1 100644 --- a/tests/lac/pointer_matrix_05.cc +++ b/tests/lac/pointer_matrix_05.cc @@ -23,11 +23,13 @@ template void -checkVmult(FullMatrix &A, Vector &V, char *name = "Test Matrix") +checkVmult(FullMatrix &A, + Vector & V, + const std::string & name = "Test Matrix") { deallog << "vmult" << std::endl; - PointerMatrix, Vector> P(&A, name); + PointerMatrix, Vector> P(&A, name.c_str()); Vector O(A.m()); P.vmult(O, V); diff --git a/tests/lac/pointer_matrix_06.cc b/tests/lac/pointer_matrix_06.cc index 75c0693b3d..ae117aa6b7 100644 --- a/tests/lac/pointer_matrix_06.cc +++ b/tests/lac/pointer_matrix_06.cc @@ -25,11 +25,11 @@ template void checkTvmult(FullMatrix &A, Vector & V, - char * name = "Test Matrix") + const std::string & name = "Test Matrix") { deallog << "Tvmult" << std::endl; - PointerMatrix, Vector> P(&A, name); + PointerMatrix, Vector> P(&A, name.c_str()); Vector O(A.m()); P.Tvmult(O, V); diff --git a/tests/lac/pointer_matrix_07.cc b/tests/lac/pointer_matrix_07.cc index 4247e73f75..4aa5503404 100644 --- a/tests/lac/pointer_matrix_07.cc +++ b/tests/lac/pointer_matrix_07.cc @@ -25,11 +25,11 @@ template void checkTvmult_add(FullMatrix &A, Vector & V, - char * name = "Test Matrix") + const std::string & name = "Test Matrix") { deallog << "Tvmult_add" << std::endl; - PointerMatrix, Vector> P(&A, name); + PointerMatrix, Vector> P(&A, name.c_str()); deallog << "Result vector set to all ones and to be added with result" << std::endl; diff --git a/tests/lac/pointer_matrix_08.cc b/tests/lac/pointer_matrix_08.cc index 2f7d209038..54d29ea26d 100644 --- a/tests/lac/pointer_matrix_08.cc +++ b/tests/lac/pointer_matrix_08.cc @@ -25,11 +25,11 @@ template void checkVmult_add(FullMatrix &A, Vector & V, - char * name = "Test Matrix") + const std::string & name = "Test Matrix") { deallog << "vmult_add" << std::endl; - PointerMatrix, Vector> P(&A, name); + PointerMatrix, Vector> P(&A, name.c_str()); deallog << "Result vector set to all ones and to be added with result" << std::endl; diff --git a/tests/lac/sparse_matrix_move.cc b/tests/lac/sparse_matrix_move.cc index c65e3765f6..ce63d8276c 100644 --- a/tests/lac/sparse_matrix_move.cc +++ b/tests/lac/sparse_matrix_move.cc @@ -48,15 +48,6 @@ graph_laplacian(const SparsityPattern &sparsity) } -SparseMatrix -graph_laplacian_move_return(const SparsityPattern &sparsity) -{ - SparseMatrix A(sparsity); - graph_laplacian(sparsity, A); - - return std::move(A); -} - int main() @@ -88,16 +79,17 @@ main() } { - // Return a sparse matrix using the move constructor - SparseMatrix A = graph_laplacian_move_return(sparsity); + // Return a sparse matrix using the move constructoir + SparseMatrix B = graph_laplacian(sparsity); + SparseMatrix A = std::move(B); deallog << A.n_nonzero_elements() << std::endl; + deallog << B.empty() << std::endl; y = 1.0; A.vmult(y, x); deallog << y.l2_norm() << std::endl; // Explicitly move a sparse matrix - SparseMatrix B; B = std::move(A); deallog << B.m() << std::endl; deallog << A.empty() << std::endl; diff --git a/tests/lac/sparse_matrix_move.output b/tests/lac/sparse_matrix_move.output index 7239c9cda8..b9bd8fe01c 100644 --- a/tests/lac/sparse_matrix_move.output +++ b/tests/lac/sparse_matrix_move.output @@ -2,6 +2,7 @@ DEAL::64 DEAL::0.00 DEAL::64 +DEAL::1 DEAL::0.00 DEAL::16 DEAL::1 diff --git a/tests/manifold/chart_manifold_06.cc b/tests/manifold/chart_manifold_06.cc index 5eeb3acd49..7981cd1829 100644 --- a/tests/manifold/chart_manifold_06.cc +++ b/tests/manifold/chart_manifold_06.cc @@ -42,20 +42,20 @@ public: virtual Point - pull_back(const Point &space_point) const + pull_back(const Point &space_point) const override { return space_point; } virtual Point - push_forward(const Point &chart_point) const + push_forward(const Point &chart_point) const override { return chart_point; } virtual DerivativeForm<1, spacedim, spacedim> - push_forward_gradient(const Point &chart_point) const + push_forward_gradient(const Point &chart_point) const override { DerivativeForm<1, spacedim, spacedim> x; for (unsigned int d = 0; d < spacedim; ++d) diff --git a/tests/numerics/project_boundary_01.cc b/tests/numerics/project_boundary_01.cc index 3404c0f9a2..7df8b0edbf 100644 --- a/tests/numerics/project_boundary_01.cc +++ b/tests/numerics/project_boundary_01.cc @@ -148,8 +148,8 @@ check() fe_list.push_back(new FE_Q(1)); function_list.push_back(new MySquareFunction(1)); - // test four different cases for the parameter: 1, 1e-20, 1e-170, 1e-800 (= 0) - double factors[] = {1., 1e-40, 1e-170, 1e-800}; + // test four different cases for the parameter: 1, 1e-20, 1e-170, 0. + double factors[] = {1., 1e-40, 1e-170, 0.}; for (unsigned int it = 0; it < 4; ++it) { deallog.push(Utilities::int_to_string(it, 1)); diff --git a/tests/opencascade/manifold_clone_01.cc b/tests/opencascade/manifold_clone_01.cc index 6136277330..e2dd1d71b8 100644 --- a/tests/opencascade/manifold_clone_01.cc +++ b/tests/opencascade/manifold_clone_01.cc @@ -54,14 +54,16 @@ main() TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(circle); NormalProjectionBoundary<2, 3> manifold_b(edge); - std::unique_ptr> clone_b = manifold_b.clone(); + std::unique_ptr> clone_b = manifold_b.clone(); + const auto & deref_clone_b = *clone_b; deallog << "typeid of NormalProjectionBoundary<2, 3> is " - << boost::core::demangle(typeid(*clone_b).name()) << std::endl; + << boost::core::demangle(typeid(deref_clone_b).name()) << std::endl; NormalProjectionManifold<2, 3> manifold_m(edge); - std::unique_ptr> clone_m = manifold_m.clone(); + std::unique_ptr> clone_m = manifold_m.clone(); + const auto & deref_clone_m = *clone_m; deallog << "typeid of NormalProjectionManifold<2, 3> is " - << boost::core::demangle(typeid(*clone_m).name()) << std::endl; + << boost::core::demangle(typeid(deref_clone_m).name()) << std::endl; } { @@ -81,15 +83,17 @@ main() DirectionalProjectionBoundary<2, 3> manifold_b(face, Point<3>(0, 0, 1)); - std::unique_ptr> clone_b = manifold_b.clone(); + std::unique_ptr> clone_b = manifold_b.clone(); + const auto & deref_clone_b = *clone_b; deallog << "typeid of DirectionalProjectionBoundary<2, 3> is " - << boost::core::demangle(typeid(*clone_b).name()) << std::endl; + << boost::core::demangle(typeid(deref_clone_b).name()) << std::endl; DirectionalProjectionManifold<2, 3> manifold_m(face, Point<3>(0, 0, 1)); - std::unique_ptr> clone_m = manifold_m.clone(); + std::unique_ptr> clone_m = manifold_m.clone(); + const auto & deref_clone_m = *clone_m; deallog << "typeid of DirectionalProjectionManifold<2, 3> is " - << boost::core::demangle(typeid(*clone_m).name()) << std::endl; + << boost::core::demangle(typeid(deref_clone_m).name()) << std::endl; } // Create a bspline passing through the points @@ -109,14 +113,16 @@ main() NormalToMeshProjectionBoundary<1, 3> manifold_b(face); - std::unique_ptr> clone_b = manifold_b.clone(); + std::unique_ptr> clone_b = manifold_b.clone(); + const auto & deref_clone_b = *clone_b; deallog << "typeid of NormalProjectionBoundary<2, 3> is " - << boost::core::demangle(typeid(*clone_b).name()) << std::endl; + << boost::core::demangle(typeid(deref_clone_b).name()) << std::endl; NormalToMeshProjectionManifold<1, 3> manifold_m(face); - std::unique_ptr> clone_m = manifold_m.clone(); + std::unique_ptr> clone_m = manifold_m.clone(); + const auto & deref_clone_m = *clone_m; deallog << "typeid of NormalProjectionManifold<2, 3> is " - << boost::core::demangle(typeid(*clone_m).name()) << std::endl; + << boost::core::demangle(typeid(deref_clone_m).name()) << std::endl; } deallog << "OK" << std::endl; -- 2.39.5