aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiretza <xiretza@xiretza.xyz>2020-05-04 21:12:30 +0200
committerXiretza <xiretza@xiretza.xyz>2020-05-07 13:39:34 +0200
commit695150b0378528233837348b598033b137b8a949 (patch)
treedf1720c84ac61299984dde8a0c0ac3bf52c99924
parenta299e606f864942c7edf90c4ad3998f4f4a346cf (diff)
downloadyosys-695150b0378528233837348b598033b137b8a949.tar.gz
yosys-695150b0378528233837348b598033b137b8a949.tar.bz2
yosys-695150b0378528233837348b598033b137b8a949.zip
Add YS_FALLTHROUGH macro to mark case fall-through
C++17 introduced [[fallthrough]], GCC and clang had their own vendored attributes before that. MSVC doesn't seem to have such a warning at all.
-rw-r--r--backends/cxxrtl/cxxrtl.cc6
-rw-r--r--backends/firrtl/firrtl.cc4
-rw-r--r--frontends/ast/genrtlil.cc7
-rw-r--r--frontends/ast/simplify.cc2
-rw-r--r--kernel/yosys.h10
5 files changed, 23 insertions, 6 deletions
diff --git a/backends/cxxrtl/cxxrtl.cc b/backends/cxxrtl/cxxrtl.cc
index e7711962f..133f56663 100644
--- a/backends/cxxrtl/cxxrtl.cc
+++ b/backends/cxxrtl/cxxrtl.cc
@@ -2346,16 +2346,22 @@ struct CxxrtlBackend : public Backend {
case 6:
worker.max_opt_level = true;
worker.run_proc_flatten = true;
+ YS_FALLTHROUGH
case 5:
worker.run_opt_clean_purge = true;
+ YS_FALLTHROUGH
case 4:
worker.localize_public = true;
+ YS_FALLTHROUGH
case 3:
worker.elide_public = true;
+ YS_FALLTHROUGH
case 2:
worker.localize_internal = true;
+ YS_FALLTHROUGH
case 1:
worker.elide_internal = true;
+ YS_FALLTHROUGH
case 0:
break;
default:
diff --git a/backends/firrtl/firrtl.cc b/backends/firrtl/firrtl.cc
index 40d05a036..f6dae1d8c 100644
--- a/backends/firrtl/firrtl.cc
+++ b/backends/firrtl/firrtl.cc
@@ -343,7 +343,7 @@ struct FirrtlWorker
switch (dir) {
case FD_INOUT:
log_warning("Instance port connection %s.%s is INOUT; treating as OUT\n", cell_type.c_str(), log_signal(it->second));
- /* FALLTHRU */
+ YS_FALLTHROUGH
case FD_OUT:
sourceExpr = firstName;
sinkExpr = secondExpr;
@@ -351,7 +351,7 @@ struct FirrtlWorker
break;
case FD_NODIRECTION:
log_warning("Instance port connection %s.%s is NODIRECTION; treating as IN\n", cell_type.c_str(), log_signal(it->second));
- /* FALLTHRU */
+ YS_FALLTHROUGH
case FD_IN:
sourceExpr = secondExpr;
sinkExpr = firstName;
diff --git a/frontends/ast/genrtlil.cc b/frontends/ast/genrtlil.cc
index 996762715..b5cdf270f 100644
--- a/frontends/ast/genrtlil.cc
+++ b/frontends/ast/genrtlil.cc
@@ -923,7 +923,7 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
}
break;
}
- /* fall through */
+ YS_FALLTHROUGH
// everything should have been handled above -> print error if not.
default:
@@ -1019,7 +1019,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
if (GetSize(children) >= 1 && children[0]->type == AST_CONSTANT) {
current_module->parameter_default_values[str] = children[0]->asParaConst();
}
- /* fall through */
+ YS_FALLTHROUGH
case AST_LOCALPARAM:
if (flag_pwires)
{
@@ -1807,7 +1807,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
is_signed = sign_hint;
return SigSpec(wire);
}
- } /* fall through */
+ }
+ YS_FALLTHROUGH
// everything should have been handled above -> print error if not.
default:
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index 252219094..892e84554 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -91,7 +91,7 @@ std::string AstNode::process_format_str(const std::string &sformat, int next_arg
case 'D':
if (got_len)
goto unsupported_format;
- /* fall through */
+ YS_FALLTHROUGH
case 'x':
case 'X':
if (next_arg >= GetSize(children))
diff --git a/kernel/yosys.h b/kernel/yosys.h
index af1e376b1..62f76a63f 100644
--- a/kernel/yosys.h
+++ b/kernel/yosys.h
@@ -155,6 +155,16 @@ extern Tcl_Obj *Tcl_ObjSetVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr, Tcl_Obj *p
# define YS_NORETURN
#endif
+#if __cplusplus >= 201703L
+# define YS_FALLTHROUGH [[fallthrough]];
+#elif defined(__GNUC__)
+# define YS_FALLTHROUGH [[gnu::fallthrough]];
+#elif defined(__clang__)
+# define YS_FALLTHROUGH [[clang::fallthrough]];
+#else
+# define YS_FALLTHROUGH
+#endif
+
YOSYS_NAMESPACE_BEGIN
// Note: All headers included in hashlib.h must be included