From ee7b399bf5b603331a0f06af3cc4cecffa29ed76 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 2 Jul 2020 21:02:49 -0400 Subject: [PATCH] Parser: Move 'static' unsupported messages down out of parser. --- src/V3Ast.h | 3 +++ src/V3LinkDot.cpp | 4 +++- src/V3LinkResolve.cpp | 10 ++++++++-- src/verilog.y | 2 +- test_regress/t/t_var_static.out | 31 +++++++++++++------------------ 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index 44102ce33..a810a9b01 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -117,6 +117,9 @@ public: inline bool operator==(const VLifetime& lhs, const VLifetime& rhs) { return lhs.m_e == rhs.m_e; } inline bool operator==(const VLifetime& lhs, VLifetime::en rhs) { return lhs.m_e == rhs; } inline bool operator==(VLifetime::en lhs, const VLifetime& rhs) { return lhs == rhs.m_e; } +inline std::ostream& operator<<(std::ostream& os, const VLifetime& rhs) { + return os << rhs.ascii(); +} //###################################################################### diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 6edddc5f5..521806c37 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -1012,7 +1012,9 @@ class LinkDotFindVisitor : public AstNVisitor { VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); return; } - if (nodep->isClassMember() && nodep->lifetime().isStatic()) { + if (nodep->isFuncLocal() && nodep->lifetime().isStatic()) { + nodep->v3warn(E_UNSUPPORTED, "Unsupported: 'static' function/task variables"); + } else if (nodep->isClassMember() && nodep->lifetime().isStatic()) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: 'static' class members"); } if (!m_statep->forScopeCreation()) { diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 50bcde21c..0e40a0879 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -111,7 +111,13 @@ private: if (m_classp && nodep->isParam()) nodep->v3warn(E_UNSUPPORTED, "Unsupported: class parameter"); if (m_ftaskp) nodep->funcLocal(true); - if (nodep->lifetime().isNone()) nodep->lifetime(m_lifetime); + if (nodep->lifetime().isNone()) { + if (nodep->isFuncLocal() && nodep->isIO()) { + nodep->lifetime(VLifetime::AUTOMATIC); + } else { + nodep->lifetime(m_lifetime); + } + } if (nodep->isSigModPublic()) { nodep->sigModPublic(false); // We're done with this attribute m_modp->modPublic(true); // Avoid flattening if signals are exposed @@ -130,7 +136,7 @@ private: if (m_classp) nodep->classMethod(true); VLifetime origLifetime = m_lifetime; { - if (!nodep->lifetime().isNone()) m_lifetime = nodep->lifetime(); + m_lifetime = nodep->lifetime(); if (m_lifetime.isNone()) m_lifetime = VLifetime::AUTOMATIC; m_ftaskp = nodep; iterateChildren(nodep); diff --git a/src/verilog.y b/src/verilog.y index a270ccf72..91efc654f 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -3779,7 +3779,7 @@ lifetimeE: // IEEE: [lifetime] lifetime: // ==IEEE: lifetime // // Note lifetime used by members is instead under memberQual - ySTATIC__ETC { $$ = VLifetime::STATIC; BBUNSUP($1, "Unsupported: Static in this context"); } + ySTATIC__ETC { $$ = VLifetime::STATIC; } | yAUTOMATIC { $$ = VLifetime::AUTOMATIC; } ; diff --git a/test_regress/t/t_var_static.out b/test_regress/t/t_var_static.out index 30e9ea620..982ff5970 100644 --- a/test_regress/t/t_var_static.out +++ b/test_regress/t/t_var_static.out @@ -1,22 +1,17 @@ -%Error-UNSUPPORTED: t/t_var_static.v:20:7: Unsupported: Static in this context +%Error-UNSUPPORTED: t/t_var_static.v:20:18: Unsupported: 'static' function/task variables + : ... In instance t 20 | static int st = 2; st++; return st; - | ^~~~~~ -%Error-UNSUPPORTED: t/t_var_static.v:26:13: Unsupported: Static in this context - 26 | function static int f_st_no (); - | ^~~~~~ -%Error-UNSUPPORTED: t/t_var_static.v:29:13: Unsupported: Static in this context - 29 | function static int f_st_st (); - | ^~~~~~ -%Error-UNSUPPORTED: t/t_var_static.v:30:7: Unsupported: Static in this context + | ^~ +%Error-UNSUPPORTED: t/t_var_static.v:27:11: Unsupported: 'static' function/task variables + : ... In instance t + 27 | int st = 2; st++; return st; + | ^~ +%Error-UNSUPPORTED: t/t_var_static.v:30:18: Unsupported: 'static' function/task variables + : ... In instance t 30 | static int st = 2; st++; return st; - | ^~~~~~ -%Error-UNSUPPORTED: t/t_var_static.v:32:13: Unsupported: Static in this context - 32 | function static int f_st_au (); - | ^~~~~~ -%Error-UNSUPPORTED: t/t_var_static.v:40:7: Unsupported: Static in this context + | ^~ +%Error-UNSUPPORTED: t/t_var_static.v:40:18: Unsupported: 'static' function/task variables + : ... In instance t 40 | static int st = 2; st++; return st; - | ^~~~~~ -%Error-UNSUPPORTED: t/t_var_static.v:73:7: Unsupported: Static in this context - 73 | static int ist2; - | ^~~~~~ + | ^~ %Error: Exiting due to