Re: [libgpiod] [PATCH 4/5] bindings: cxx: Fix compile errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



śr., 7 sie 2019 o 21:51 Alexander Stein <alexander.stein@xxxxxxxxxxx>
napisał(a):
>
> This fixes the following compile errors:
> tests-event.cpp:152:3: error: cannot declare reference to
> 'class std::system_error&', which is not a typedef or a template type
> argument
>   152 |   REQUIRE_THROWS_AS(line.event_get_fd(), ::std::system_error&);
>

Hi Alexander, thanks for working on this!

I'm getting the following warning when I don't use the reference:

In file included from tests-line.cpp:8:
tests-line.cpp: In function ‘void ____C_A_T_C_H____T_E_S_T____24()’:
tests-line.cpp:254:45: warning: catching polymorphic type ‘class
std::system_error’ by value [-Wcatch-value=]
  REQUIRE_THROWS_AS(line.get_value(), ::std::system_error);
                                             ^~~~~~~~~~~~
I'm also not getting any build errors with my current next or master
branch. My gcc is:

gcc (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Bart

> Signed-off-by: Alexander Stein <alexander.stein@xxxxxxxxxxx>
> ---
>  bindings/cxx/tests/tests-chip.cpp  |  8 ++++----
>  bindings/cxx/tests/tests-event.cpp |  4 ++--
>  bindings/cxx/tests/tests-line.cpp  | 16 ++++++++--------
>  3 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/bindings/cxx/tests/tests-chip.cpp b/bindings/cxx/tests/tests-chip.cpp
> index 11c2d4c..c9eb8e5 100644
> --- a/bindings/cxx/tests/tests-chip.cpp
> +++ b/bindings/cxx/tests/tests-chip.cpp
> @@ -107,7 +107,7 @@ TEST_CASE("Uninitialized GPIO chip behaves correctly", "[chip]")
>
>         SECTION("using uninitialized chip throws logic_error")
>         {
> -               REQUIRE_THROWS_AS(chip.name(), ::std::logic_error&);
> +               REQUIRE_THROWS_AS(chip.name(), ::std::logic_error);
>         }
>  }
>
> @@ -139,7 +139,7 @@ TEST_CASE("GPIO chip can be opened with the open() method with implicit lookup",
>
>  TEST_CASE("Trying to open a nonexistent chip throws system_error", "[chip]")
>  {
> -       REQUIRE_THROWS_AS(::gpiod::chip("nonexistent-chip"), ::std::system_error&);
> +       REQUIRE_THROWS_AS(::gpiod::chip("nonexistent-chip"), ::std::system_error);
>  }
>
>  TEST_CASE("Chip object can be reset", "[chip]")
> @@ -244,12 +244,12 @@ TEST_CASE("Errors occurring when retrieving lines are correctly reported", "[chi
>
>         SECTION("invalid offset (single line)")
>         {
> -               REQUIRE_THROWS_AS(chip.get_line(9), ::std::out_of_range&);
> +               REQUIRE_THROWS_AS(chip.get_line(9), ::std::out_of_range);
>         }
>
>         SECTION("invalid offset (multiple lines)")
>         {
> -               REQUIRE_THROWS_AS(chip.get_lines({ 1, 19, 4, 7 }), ::std::out_of_range&);
> +               REQUIRE_THROWS_AS(chip.get_lines({ 1, 19, 4, 7 }), ::std::out_of_range);
>         }
>
>         SECTION("line not found by name")
> diff --git a/bindings/cxx/tests/tests-event.cpp b/bindings/cxx/tests/tests-event.cpp
> index b34347f..b41cf7e 100644
> --- a/bindings/cxx/tests/tests-event.cpp
> +++ b/bindings/cxx/tests/tests-event.cpp
> @@ -149,7 +149,7 @@ TEST_CASE("It's possible to retrieve the event file descriptor", "[event][line]"
>
>         SECTION("error if not requested")
>         {
> -               REQUIRE_THROWS_AS(line.event_get_fd(), ::std::system_error&);
> +               REQUIRE_THROWS_AS(line.event_get_fd(), ::std::system_error);
>         }
>
>         SECTION("error if requested for values")
> @@ -157,7 +157,7 @@ TEST_CASE("It's possible to retrieve the event file descriptor", "[event][line]"
>                 config.request_type = ::gpiod::line_request::DIRECTION_INPUT;
>
>                 line.request(config);
> -               REQUIRE_THROWS_AS(line.event_get_fd(), ::std::system_error&);
> +               REQUIRE_THROWS_AS(line.event_get_fd(), ::std::system_error);
>         }
>  }
>
> diff --git a/bindings/cxx/tests/tests-line.cpp b/bindings/cxx/tests/tests-line.cpp
> index e827e60..08ff1e8 100644
> --- a/bindings/cxx/tests/tests-line.cpp
> +++ b/bindings/cxx/tests/tests-line.cpp
> @@ -122,7 +122,7 @@ TEST_CASE("Line bulk object works correctly", "[line][bulk]")
>         {
>                 auto lines = chip.get_all_lines();
>
> -               REQUIRE_THROWS_AS(lines.get(11), ::std::out_of_range&);
> +               REQUIRE_THROWS_AS(lines.get(11), ::std::out_of_range);
>         }
>  }
>
> @@ -242,7 +242,7 @@ TEST_CASE("Exported line can be released", "[line]")
>         line.release();
>
>         REQUIRE_FALSE(line.is_requested());
> -       REQUIRE_THROWS_AS(line.get_value(), ::std::system_error&);
> +       REQUIRE_THROWS_AS(line.get_value(), ::std::system_error);
>  }
>
>  TEST_CASE("Uninitialized GPIO line behaves correctly", "[line]")
> @@ -256,7 +256,7 @@ TEST_CASE("Uninitialized GPIO line behaves correctly", "[line]")
>
>         SECTION("using uninitialized line throws logic_error")
>         {
> -               REQUIRE_THROWS_AS(line.name(), ::std::logic_error&);
> +               REQUIRE_THROWS_AS(line.name(), ::std::logic_error);
>         }
>  }
>
> @@ -271,7 +271,7 @@ TEST_CASE("Uninitialized GPIO line_bulk behaves correctly", "[line][bulk]")
>
>         SECTION("using uninitialized line_bulk throws logic_error")
>         {
> -               REQUIRE_THROWS_AS(bulk.get(0), ::std::logic_error&);
> +               REQUIRE_THROWS_AS(bulk.get(0), ::std::logic_error);
>         }
>  }
>
> @@ -289,7 +289,7 @@ TEST_CASE("Cannot request the same line twice", "[line]")
>                 auto line = chip.get_line(3);
>
>                 REQUIRE_NOTHROW(line.request(config));
> -               REQUIRE_THROWS_AS(line.request(config), ::std::system_error&);
> +               REQUIRE_THROWS_AS(line.request(config), ::std::system_error);
>         }
>
>         SECTION("request the same line twice in line_bulk")
> @@ -300,7 +300,7 @@ TEST_CASE("Cannot request the same line twice", "[line]")
>                  */
>                 auto lines = chip.get_lines({ 2, 3, 4, 4 });
>
> -               REQUIRE_THROWS_AS(lines.request(config), ::std::system_error&);
> +               REQUIRE_THROWS_AS(lines.request(config), ::std::system_error);
>         }
>  }
>
> @@ -312,12 +312,12 @@ TEST_CASE("Cannot get/set values of unrequested lines", "[line]")
>
>         SECTION("get value")
>         {
> -               REQUIRE_THROWS_AS(line.get_value(), ::std::system_error&);
> +               REQUIRE_THROWS_AS(line.get_value(), ::std::system_error);
>         }
>
>         SECTION("set value")
>         {
> -               REQUIRE_THROWS_AS(line.set_value(1), ::std::system_error&);
> +               REQUIRE_THROWS_AS(line.set_value(1), ::std::system_error);
>         }
>  }
>
> --
> 2.22.0
>




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux