From e896f0c8e6d987de1a56b5a240e9eb49e9115884 Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 14 Oct 2014 09:02:33 -0700 Subject: [PATCH] Remove some compile warnings in the vhdlpp code --- vhdlpp/parse.y | 20 +++++++++++++------- vhdlpp/subprogram.cc | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/vhdlpp/parse.y b/vhdlpp/parse.y index 7c37a7e0b..ecde6b0b2 100644 --- a/vhdlpp/parse.y +++ b/vhdlpp/parse.y @@ -370,7 +370,7 @@ static void touchup_interface_for_functions(std::list*ports) %type else_when_waveform %type else_when_waveforms -%type function_specification subprogram_specification +%type function_specification subprogram_specification subprogram_body_start %% @@ -2201,13 +2201,18 @@ signal_assignment_statement } ; +subprogram_body_start + : subprogram_specification K_is + { assert(!active_sub); + active_sub = $1; + $$ = $1; } + ; + /* This is a function/task body. This may have a matching subprogram declaration, and if so it will be in the active scope. */ subprogram_body /* IEEE 1076-2008 P4.3 */ - : subprogram_specification K_is - { active_sub = $1; } - subprogram_declarative_part + : subprogram_body_start subprogram_declarative_part K_begin subprogram_statement_part K_end subprogram_kind_opt identifier_opt ';' { Subprogram*prog = $1; @@ -2219,19 +2224,20 @@ subprogram_body /* IEEE 1076-2008 P4.3 */ errormsg(@1, "Subprogram specification for %s doesn't match specification in package header.\n", prog->name().str()); } prog->transfer_from(*active_scope); - prog->set_program_body($6); + prog->set_program_body($4); active_scope->bind_name(prog->name(), prog); active_sub = NULL; } - | subprogram_specification K_is + | subprogram_body_start subprogram_declarative_part K_begin error K_end subprogram_kind_opt identifier_opt ';' { errormsg(@2, "Syntax errors in subprogram body.\n"); yyerrok; + active_sub = NULL; if ($1) delete $1; - if ($8) delete[]$8; + if ($7) delete[]$7; } ; diff --git a/vhdlpp/subprogram.cc b/vhdlpp/subprogram.cc index 67b5c8cab..5814bfdbf 100644 --- a/vhdlpp/subprogram.cc +++ b/vhdlpp/subprogram.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 2013-2014 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -96,7 +96,7 @@ const InterfacePort*Subprogram::find_param(perm_string nam) const const VType*Subprogram::peek_param_type(int idx) const { - if(!ports_ || idx >= ports_->size()) + if(!ports_ || idx < 0 || (size_t)idx >= ports_->size()) return NULL; std::list::const_iterator p = ports_->begin();