From e79d226082f66071a06683a70a4b7a6b89be335f Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Mon, 14 May 2018 21:30:56 +0100 Subject: [PATCH] Don't allow non-vectorable arguments to $signed/$unsigned. This led to an assertion failure in many cases (see br1029). 1364-2012 indicates it is illegal. (cherry picked from commit 87c01c55c05a13bf2a471a8600346809ab85040d) --- elab_expr.cc | 9 ++++++++- vhdlpp/std_funcs.cc | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index eae0a0df5..14038e0f3 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2016 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2018 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -1446,6 +1446,13 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope, return 0; } + if (!type_is_vectorable(expr_type_)) { + cerr << get_fileline() << ": error: The argument to " + << name << " must be a vector type." << endl; + des->errors += 1; + return 0; + } + if (debug_elaborate) { cerr << get_fileline() << ": PECallFunction::elaborate_sfunc_: " << name << " expression is the argument cast to expr_wid=" << expr_wid << endl; diff --git a/vhdlpp/std_funcs.cc b/vhdlpp/std_funcs.cc index ec843dd13..89448e483 100644 --- a/vhdlpp/std_funcs.cc +++ b/vhdlpp/std_funcs.cc @@ -1,5 +1,5 @@ /* - * Copyright CERN 2015 + * Copyright CERN 2016-2018 * @author Maciej Suminski (maciej.suminski@cern.ch) * * This source code is free software; you can redistribute it @@ -120,7 +120,7 @@ void preload_std_funcs(void) std::list*fn_integer_args = new std::list(); fn_integer_args->push_back(new InterfacePort(&primitive_INTEGER)); fn_integer = new SubprogramBuiltin(perm_string::literal("integer"), - perm_string::literal("$signed"), + perm_string::literal("int'"), fn_integer_args, &primitive_INTEGER); std_subprograms[fn_integer->name()] = fn_integer;