From 163a91355916a0c3893a6468e02ee05f285ffce7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 22 Mar 2016 15:50:09 +0100 Subject: [PATCH] vhdlpp: Specify lifetime for variables. --- vhdlpp/scope.h | 2 ++ vhdlpp/subprogram.h | 1 + vhdlpp/vsignal.cc | 3 +++ 3 files changed, 6 insertions(+) diff --git a/vhdlpp/scope.h b/vhdlpp/scope.h index 118dbb862..f92a74403 100644 --- a/vhdlpp/scope.h +++ b/vhdlpp/scope.h @@ -67,6 +67,8 @@ class ScopeBase { // type is returned, otherwise NULL. const VTypeEnum* is_enum_name(perm_string name) const; + virtual bool is_subprogram() const { return false; } + // Moves signals, variables and components from another scope to // this one. After the transfer new_* maps are cleared in the source scope. enum transfer_type_t { SIGNALS = 1, VARIABLES = 2, COMPONENTS = 4, ALL = 0xffff }; diff --git a/vhdlpp/subprogram.h b/vhdlpp/subprogram.h index 7b4bcceee..d06f82461 100644 --- a/vhdlpp/subprogram.h +++ b/vhdlpp/subprogram.h @@ -55,6 +55,7 @@ class SubprogramBody : public LineInfo, public ScopeBase { void dump(std::ostream&fd) const; const SubprogramHeader*header() const { return header_; } + bool is_subprogram() const { return true; } private: std::list*statements_; diff --git a/vhdlpp/vsignal.cc b/vhdlpp/vsignal.cc index 5065356e0..5d5eca4ff 100644 --- a/vhdlpp/vsignal.cc +++ b/vhdlpp/vsignal.cc @@ -21,6 +21,7 @@ # include "vsignal.h" # include "expression.h" +# include "scope.h" # include "vtype.h" # include "std_types.h" # include @@ -79,6 +80,8 @@ int Variable::emit(ostream&out, Entity*ent, ScopeBase*scope, bool initialize) { int errors = 0; + out << (!scope->is_subprogram() ? "static " : "automatic "); + VType::decl_t decl; type_elaborate_(decl); decl.reg_flag = true;