From 7d450229bc23c10ff9fd2469764bf945cbab04d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20B=C3=B6l=C3=B6ny?= Date: Sun, 24 Jun 2018 14:34:26 +0200 Subject: [core] Fix GCC8's new -Wcatch-value warnings Polymorphic types shouldn't be caught by value, as the warning message says. Catch them by constant reference instead. --- bin/offline.cpp | 6 +++--- bin/render.cpp | 6 +++--- platform/default/mbgl/storage/offline_database.cpp | 2 +- platform/default/mbgl/storage/offline_download.cpp | 2 +- platform/glfw/main.cpp | 6 +++--- src/mbgl/style/expression/coercion.cpp | 2 +- test/storage/offline_database.test.cpp | 2 +- test/style/style.test.cpp | 2 +- test/style/style_layer.test.cpp | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/offline.cpp b/bin/offline.cpp index 65396a88fb..8b42ab7b72 100644 --- a/bin/offline.cpp +++ b/bin/offline.cpp @@ -33,14 +33,14 @@ int main(int argc, char *argv[]) { try { argumentParser.ParseCLI(argc, argv); - } catch (args::Help) { + } catch (const args::Help&) { std::cout << argumentParser; exit(0); - } catch (args::ParseError e) { + } catch (const args::ParseError& e) { std::cerr << e.what() << std::endl; std::cerr << argumentParser; exit(1); - } catch (args::ValidationError e) { + } catch (const args::ValidationError& e) { std::cerr << e.what() << std::endl; std::cerr << argumentParser; exit(2); diff --git a/bin/render.cpp b/bin/render.cpp index 6ceb32eb00..1e7b210a4c 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -39,14 +39,14 @@ int main(int argc, char *argv[]) { try { argumentParser.ParseCLI(argc, argv); - } catch (args::Help) { + } catch (const args::Help&) { std::cout << argumentParser; exit(0); - } catch (args::ParseError e) { + } catch (const args::ParseError& e) { std::cerr << e.what() << std::endl; std::cerr << argumentParser; exit(1); - } catch (args::ValidationError e) { + } catch (const args::ValidationError& e) { std::cerr << e.what() << std::endl; std::cerr << argumentParser; exit(2); diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp index 24fc0f2335..92e534634d 100644 --- a/platform/default/mbgl/storage/offline_database.cpp +++ b/platform/default/mbgl/storage/offline_database.cpp @@ -658,7 +658,7 @@ void OfflineDatabase::putRegionResources(int64_t regionID, const std::list optional { try { return util::stof(s); - } catch(std::exception) { + } catch (const std::exception&) { return optional(); } }, diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp index 36b71bc4b4..10343ec305 100644 --- a/test/storage/offline_database.test.cpp +++ b/test/storage/offline_database.test.cpp @@ -631,7 +631,7 @@ TEST(OfflineDatabase, BatchInsertionMapboxTileCountExceeded) { try { db.putRegionResources(region.getID(), resources, status); EXPECT_FALSE(true); - } catch (MapboxTileLimitExceededException) { + } catch (const MapboxTileLimitExceededException&) { // Expected } diff --git a/test/style/style.test.cpp b/test/style/style.test.cpp index 9bdab37ac6..f2055c88f8 100644 --- a/test/style/style.test.cpp +++ b/test/style/style.test.cpp @@ -65,7 +65,7 @@ TEST(Style, DuplicateSource) { try { style.addSource(std::make_unique("sourceId", "mapbox://mapbox.mapbox-terrain-v2")); FAIL() << "Should not have been allowed to add a duplicate source id"; - } catch (std::runtime_error) { + } catch (const std::runtime_error&) { // Expected } } diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp index 624ed088c3..61516a2de9 100644 --- a/test/style/style_layer.test.cpp +++ b/test/style/style_layer.test.cpp @@ -285,7 +285,7 @@ TEST(Layer, DuplicateLayer) { try { style.addLayer(std::make_unique("line", "unusedsource")); FAIL() << "Should not have been allowed to add a duplicate layer id"; - } catch (const std::runtime_error e) { + } catch (const std::runtime_error& e) { // Expected ASSERT_STREQ("Layer line already exists", e.what()); } -- cgit v1.2.1