From a581e0ef0e287daf75616ff4a72bee88ed16baba Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 7 Feb 2013 17:06:54 -0800 Subject: [PATCH] vlog95: Report zero argument functions are not supported. --- tgt-vlog95/expr.c | 5 ++++- tgt-vlog95/scope.c | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tgt-vlog95/expr.c b/tgt-vlog95/expr.c index d490c6a7a..3d1c6a293 100644 --- a/tgt-vlog95/expr.c +++ b/tgt-vlog95/expr.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2012 Cary R. (cygcary@yahoo.com) + * Copyright (C) 2011-2013 Cary R. (cygcary@yahoo.com) * * 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 @@ -456,6 +456,9 @@ static void emit_expr_func(ivl_scope_t scope, ivl_expr_t expr, unsigned wid) } emit_expr(scope, ivl_expr_parm(expr, count), 0); fprintf(vlog_out, ")"); + /* User functions without arguments are not supported. */ + } else if (ivl_expr_type(expr) == IVL_EX_UFUNC) { + fprintf(vlog_out, "()"); } } diff --git a/tgt-vlog95/scope.c b/tgt-vlog95/scope.c index f20da5fd0..a0354c2c1 100644 --- a/tgt-vlog95/scope.c +++ b/tgt-vlog95/scope.c @@ -717,7 +717,14 @@ int emit_scope(ivl_scope_t scope, ivl_scope_t parent) case IVL_SCT_FUNCTION: assert(indent != 0); fprintf(vlog_out, "\n%*cfunction", indent, ' '); - assert(ivl_scope_ports(scope) >= 2); + if (ivl_scope_ports(scope) < 2) { + fprintf(stderr, "%s:%u: vlog95 error: Function (%s) has " + "no argments (or return value).\n", + ivl_scope_file(scope), + ivl_scope_lineno(scope), + ivl_scope_tname(scope)); + vlog_errors += 1; + } /* The function return information is the zero port. */ emit_func_return(ivl_scope_port(scope, 0)); fprintf(vlog_out, " ");