Enable [[noreturn]] some.

This commit is contained in:
Bruce Mitchener 2019-04-08 18:52:20 +07:00 committed by Victor Zverovich
parent 2808395481
commit aeb5ad3ce1
5 changed files with 25 additions and 25 deletions

View File

@ -348,32 +348,32 @@ FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin,
}
struct chrono_format_checker {
void report_no_date() { FMT_THROW(format_error("no date")); }
FMT_NORETURN void report_no_date() { FMT_THROW(format_error("no date")); }
template <typename Char> void on_text(const Char*, const Char*) {}
void on_abbr_weekday() { report_no_date(); }
void on_full_weekday() { report_no_date(); }
void on_dec0_weekday(numeric_system) { report_no_date(); }
void on_dec1_weekday(numeric_system) { report_no_date(); }
void on_abbr_month() { report_no_date(); }
void on_full_month() { report_no_date(); }
FMT_NORETURN void on_abbr_weekday() { report_no_date(); }
FMT_NORETURN void on_full_weekday() { report_no_date(); }
FMT_NORETURN void on_dec0_weekday(numeric_system) { report_no_date(); }
FMT_NORETURN void on_dec1_weekday(numeric_system) { report_no_date(); }
FMT_NORETURN void on_abbr_month() { report_no_date(); }
FMT_NORETURN void on_full_month() { report_no_date(); }
void on_24_hour(numeric_system) {}
void on_12_hour(numeric_system) {}
void on_minute(numeric_system) {}
void on_second(numeric_system) {}
void on_datetime(numeric_system) { report_no_date(); }
void on_loc_date(numeric_system) { report_no_date(); }
void on_loc_time(numeric_system) { report_no_date(); }
void on_us_date() { report_no_date(); }
void on_iso_date() { report_no_date(); }
FMT_NORETURN void on_datetime(numeric_system) { report_no_date(); }
FMT_NORETURN void on_loc_date(numeric_system) { report_no_date(); }
FMT_NORETURN void on_loc_time(numeric_system) { report_no_date(); }
FMT_NORETURN void on_us_date() { report_no_date(); }
FMT_NORETURN void on_iso_date() { report_no_date(); }
void on_12_hour_time() {}
void on_24_hour_time() {}
void on_iso_time() {}
void on_am_pm() {}
void on_duration_value() {}
void on_duration_unit() {}
void on_utc_offset() { report_no_date(); }
void on_tz_name() { report_no_date(); }
FMT_NORETURN void on_utc_offset() { report_no_date(); }
FMT_NORETURN void on_tz_name() { report_no_date(); }
};
template <typename Int> inline int to_int(Int value) {

View File

@ -143,6 +143,12 @@
# endif
#endif
#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn)
# define FMT_NORETURN [[noreturn]]
#else
# define FMT_NORETURN
#endif
#ifndef FMT_DEPRECATED
# if (FMT_HAS_CPP_ATTRIBUTE(deprecated) && __cplusplus >= 201402L) || \
FMT_MSC_VER >= 1900
@ -350,7 +356,7 @@ struct error_handler {
FMT_CONSTEXPR error_handler(const error_handler&) {}
// This function is intentionally not constexpr to give a compile-time error.
FMT_API void on_error(const char* message);
FMT_API FMT_NORETURN void on_error(const char* message);
};
// GCC 4.6.x cannot expand `T...`.

View File

@ -2621,7 +2621,7 @@ template <typename Range> class basic_writer {
num_writer{abs_value, size, sep});
}
void on_error() { FMT_THROW(format_error("invalid type specifier")); }
FMT_NORETURN void on_error() { FMT_THROW(format_error("invalid type specifier")); }
};
// Writes a formatted integer.
@ -2858,7 +2858,7 @@ struct float_spec_handler {
if (type == 'A') upper = true;
}
void on_error() { FMT_THROW(format_error("invalid type specifier")); }
FMT_NORETURN void on_error() { FMT_THROW(format_error("invalid type specifier")); }
};
template <typename Range>

View File

@ -22,12 +22,6 @@
#undef max
#if FMT_HAS_CPP_ATTRIBUTE(noreturn)
# define FMT_NORETURN [[noreturn]]
#else
# define FMT_NORETURN
#endif
using fmt::internal::fp;
template <bool is_iec559> void test_construct_from_double() {

View File

@ -52,9 +52,9 @@ int SingleEvaluationTest::b_;
void do_nothing() {}
void throw_exception() { throw std::runtime_error("test"); }
FMT_NORETURN void throw_exception() { throw std::runtime_error("test"); }
void throw_system_error() { throw fmt::system_error(EDOM, "test"); }
FMT_NORETURN void throw_system_error() { throw fmt::system_error(EDOM, "test"); }
// Tests that when EXPECT_THROW_MSG fails, it evaluates its message argument
// exactly once.