diff --git a/common/nextpnr.h b/common/nextpnr.h index 9d46b654..6a45875b 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -44,7 +44,7 @@ #if defined(__GNUC__) || defined(__clang__) #define NPNR_ATTRIBUTE(...) __attribute__((__VA_ARGS__)) -#define NPNR_NORETURN +#define NPNR_NORETURN __attribute__((noreturn)) #define NPNR_DEPRECATED __attribute__((deprecated)) #define NPNR_PACKED_STRUCT(...) __VA_ARGS__ __attribute__((packed)) #elif defined(_MSC_VER) @@ -78,8 +78,15 @@ inline void except_assert_impl(bool expr, std::string message, std::string expr_ throw assertion_failure(message, expr_str, filename, line); } +NPNR_NORETURN +inline void assert_false_impl(std::string message, std::string filename, int line) +{ + throw assertion_failure(message, "false", filename, line); +} + #define NPNR_ASSERT(cond) except_assert_impl((cond), #cond, #cond, __FILE__, __LINE__) #define NPNR_ASSERT_MSG(cond, msg) except_assert_impl((cond), msg, #cond, __FILE__, __LINE__) +#define NPNR_ASSERT_FALSE(msg) assert_false_impl(msg, __FILE__, __LINE__) struct BaseCtx; struct Context; diff --git a/ice40/bitstream.cc b/ice40/bitstream.cc index 33c4d97b..98a7a0e4 100644 --- a/ice40/bitstream.cc +++ b/ice40/bitstream.cc @@ -36,7 +36,7 @@ const ConfigEntryPOD &find_config(const TileInfoPOD &tile, const std::string &na return tile.entries[i]; } } - NPNR_ASSERT(false); + NPNR_ASSERT_FALSE("unable to find config bit " + name); } std::tuple get_ieren(const BitstreamInfoPOD &bi, int8_t x, int8_t y, int8_t z) @@ -124,7 +124,7 @@ void write_asc(const Context *ctx, std::ostream &out) out << ".device 5k" << std::endl; break; default: - NPNR_ASSERT(false); + NPNR_ASSERT_FALSE("unsupported device type"); } // Set pips for (auto pip : ctx->getPips()) {