Philippe Proulx 4e8640ed90
Fix: enable FMT_NORETURN without exception support too (#3917)
When building `format.cc` as such with GCC 13.2.1:

    $ g++ -c format.cc -DFMT_EXCEPTIONS=0 -Wmissing-noreturn -Werror

I get:

    In file included from format.cc:8:
    fmt/format-inl.h: In function ‘void fmt::v10::detail::assert_fail(const char*, int, const char*)’:
    fmt/format-inl.h:30:15: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
       30 | FMT_FUNC void assert_fail(const char* file, int line, const char* message) {
          |               ^~~~~~~~~~~
    fmt/format-inl.h: In function ‘void fmt::v10::report_error(const char*)’:
    fmt/format-inl.h:129:15: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
      129 | FMT_FUNC void report_error(const char* message) {
          |               ^~~~~~~~~~~~
    cc1plus: all warnings being treated as errors

Note that, with `FMT_EXCEPTIONS` defined to 0:

‣ report_error(const char *) uses FMT_THROW() which expands to calling
  assert_fail().

‣ assert_fail() calls std::terminate() which has the `[[noreturn]]`
  attribute since C++11 [1].

Therefore, with `FMT_EXCEPTIONS` defined to 0, both assert_fail() and
report_error() need to have the `[[noreturn]]` attribute too (if
available). In other words, `FMT_NORETURN` doesn't depend on
`FMT_EXCEPTIONS`.

Also adding `FMT_NORETURN` to two on_error() functions which call
report_error(const char *).

Other report_error() overloads eventually return, therefore they don't
need `FMT_NORETURN`.

[1]: https://en.cppreference.com/w/cpp/error/terminate

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
2024-04-04 17:15:18 -07:00
..
args.h Remove dependency on string_view 2024-01-03 18:49:45 -08:00
base.h Fix: enable FMT_NORETURN without exception support too (#3917) 2024-04-04 17:15:18 -07:00
chrono.h Coding conventions and minor fixes 2024-04-05 08:36:45 +09:00
color.h Simplify color formatting 2024-01-31 18:30:23 -08:00
compile.h Cleanup copy functions and move to base.h 2024-01-13 09:31:20 -08:00
core.h Update core.h 2024-01-10 06:57:22 -08:00
format-inl.h Guard against usage of _isatty when header was not included (#3880) 2024-03-08 13:34:46 -08:00
format.h Fix: enable FMT_NORETURN without exception support too (#3917) 2024-04-04 17:15:18 -07:00
os.h Make line buffering test less flaky 2024-03-20 16:45:50 +09:00
ostream.h Invert dependencies 2024-01-13 10:30:44 -08:00
printf.h Fix warning C4365 emitted from printf.h (#3865) 2024-02-23 16:33:21 -08:00
ranges.h Simplify range formatter 2024-03-09 08:23:12 -08:00
std.h Improve std::complex formatter to be compatible with P2197R0 (#3900) 2024-03-20 13:31:32 -07:00
xchar.h Fix ambiguous call 2024-03-17 17:16:53 -07:00