From c99fbde0eb0b1b9b725ba2fead13d3210ce961a7 Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Thu, 4 Feb 2021 14:47:45 -0800 Subject: Mark IdString and IdStringList single argument constructors explicit. Single argument constructors will silently convert to that type. This is typically not the right thing to do. For example, the nexus and ice40 arch_pybindings.h files were incorrectly parsing bel name strings, etc. Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- common/nextpnr.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 78bbf66e..2445bed1 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -110,7 +110,8 @@ struct IdString static void initialize_add(const BaseCtx *ctx, const char *s, int idx); - constexpr IdString(int index = 0) : index(index) {} + constexpr IdString() : index(0) {} + explicit constexpr IdString(int index) : index(index) {} void set(const BaseCtx *ctx, const std::string &s); @@ -229,9 +230,9 @@ struct IdStringList SSOArray ids; IdStringList(){}; - IdStringList(size_t n) : ids(n, IdString()){}; - IdStringList(IdString id) : ids(1, id){}; - template IdStringList(const Tlist &list) : ids(list){}; + explicit IdStringList(size_t n) : ids(n, IdString()){}; + explicit IdStringList(IdString id) : ids(1, id){}; + template explicit IdStringList(const Tlist &list) : ids(list){}; static IdStringList parse(Context *ctx, const std::string &str); void build_str(const Context *ctx, std::string &str) const; -- cgit v1.2.3