From 327cdc77a30e6e98d7858cd53a3f81d57790cc90 Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 10 Dec 2009 12:50:53 -0800 Subject: [PATCH] Add some casts in tgt-vhdl to remove warnings. The Cygwin compiler is a bit picky. This patch adds some casts to remove compilation warnings. In the past I have had warnings off because of problems with the STL, but we may as well get rid of the warnings we can. It also does not recognize that an assert(0) or assert(false) ends a routine so it complains about no return at end of function or variables not being defined. (cherry picked from commit 3f12a401ebad50a0bf272454412195b93c64cbaf) --- tgt-vhdl/cast.cc | 17 +++++++++-------- tgt-vhdl/state.cc | 1 + tgt-vhdl/stmt.cc | 4 ++-- tgt-vhdl/support.cc | 7 ++++--- tgt-vhdl/vhdl_syntax.hh | 3 ++- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/tgt-vhdl/cast.cc b/tgt-vhdl/cast.cc index 230108b12..22f6b89f4 100644 --- a/tgt-vhdl/cast.cc +++ b/tgt-vhdl/cast.cc @@ -1,7 +1,7 @@ /* * Generate code to convert between VHDL types. * - * Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2009 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,8 @@ vhdl_expr *vhdl_expr::cast(const vhdl_type *to) assert(false); } } + assert(false); + return NULL; } /* @@ -140,9 +142,8 @@ vhdl_expr *vhdl_expr::to_boolean() conv->add_expr(this); return conv; } - else { - assert(false); - } + assert(false); + return NULL; } /* @@ -180,8 +181,8 @@ vhdl_expr *vhdl_expr::to_std_logic() return ah; } - else - assert(false); + assert(false); + return NULL; } /* @@ -274,8 +275,8 @@ vhdl_expr *vhdl_const_bits::to_vector(vhdl_type_name_t name, int w) value_.resize(w, sign_bit()); return this; } - else - assert(false); + assert(false); + return NULL; } vhdl_expr *vhdl_const_bits::to_integer() diff --git a/tgt-vhdl/state.cc b/tgt-vhdl/state.cc index 7acab014c..0ced93f27 100644 --- a/tgt-vhdl/state.cc +++ b/tgt-vhdl/state.cc @@ -139,6 +139,7 @@ ivl_signal_t find_signal_named(const std::string &name, const vhdl_scope *scope) return (*it).first; } assert(false); + return NULL; } // Compare the name of an entity against a string diff --git a/tgt-vhdl/stmt.cc b/tgt-vhdl/stmt.cc index d5f94c1e5..774ce9d06 100644 --- a/tgt-vhdl/stmt.cc +++ b/tgt-vhdl/stmt.cc @@ -239,9 +239,9 @@ assign_for(vhdl_decl::assign_type_t atype, vhdl_var_ref *lhs, vhdl_expr *rhs) return new vhdl_assign_stmt(lhs, rhs); case vhdl_decl::ASSIGN_NONBLOCK: return new vhdl_nbassign_stmt(lhs, rhs); - default: - assert(false); } + assert(false); + return NULL; } /* diff --git a/tgt-vhdl/support.cc b/tgt-vhdl/support.cc index 01eb16869..5001d5bc8 100644 --- a/tgt-vhdl/support.cc +++ b/tgt-vhdl/support.cc @@ -1,7 +1,7 @@ /* * Support functions for VHDL output. * - * Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2009 Nick Gasson (nick@nickg.me.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,6 +51,7 @@ const char *support_function::function_name(support_function_t type) default: assert(false); } + return "Invalid"; } vhdl_type *support_function::function_type(support_function_t type) @@ -74,9 +75,9 @@ vhdl_type *support_function::function_type(support_function_t type) return new vhdl_type(VHDL_TYPE_UNSIGNED); case SF_LOGIC_TO_INTEGER: return vhdl_type::integer(); - default: - assert(false); } + assert(false); + return vhdl_type::boolean(); } void support_function::emit_ternary(std::ostream &of, int level) const diff --git a/tgt-vhdl/vhdl_syntax.hh b/tgt-vhdl/vhdl_syntax.hh index 326f70084..d1a278aae 100644 --- a/tgt-vhdl/vhdl_syntax.hh +++ b/tgt-vhdl/vhdl_syntax.hh @@ -571,7 +571,8 @@ public: // For some sorts of declarations it doesn't make sense // to assign to it so calling assignment_type just raises // an assertion failure - virtual assign_type_t assignment_type() const { assert(false); } + virtual assign_type_t assignment_type() const { assert(false); + return ASSIGN_BLOCK; } // True if this declaration can be read from virtual bool is_readable() const { return true; }