From c292f77f286b5c8b990bf701f2bee869ffeda789 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 9 Jan 2012 19:08:20 -0800 Subject: [PATCH] V0.9: Remove crash for function def with zero args and warn on calls Normal Verilog does not allow a function to be defined without at least an input argument. This patch fixes a crash that was happening when a function with no arguments was defined. It also adds checks and prints a descriptive error message when calling a function without an argument. The development branch allows this in SV. --- parse.y | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/parse.y b/parse.y index 003ea90a9..d8f4162e5 100644 --- a/parse.y +++ b/parse.y @@ -1,7 +1,7 @@ %{ /* - * Copyright (c) 1998-2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2012 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -1318,6 +1318,16 @@ expr_primary delete[]$1; $$ = tmp; } + | hierarchy_identifier '(' ')' + { yyerror(@1, "error: function calls must have at least one " + "input argument."); + yyerrok; + } + | SYSTEM_IDENTIFIER '(' ')' + { yyerror(@1, "error: system function calls must have at least one " + "input argument."); + yyerrok; + } /* Many of the VAMS built-in functions are available as builtin functions with $system_function equivalents. */ @@ -2396,7 +2406,10 @@ module_item } | K_function automatic_opt function_range_or_type_opt IDENTIFIER error K_endfunction { - assert(current_function == 0); + if (current_function != 0) { + pform_pop_scope(); + current_function = 0; + } delete[]$4; }