diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index 5fcf49490..22778a657 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -111,6 +111,7 @@ struct V3ParseBisonYYSType final { AstNode* scp; // Symbol table scope for future lookups int token; // Read token, aka tok VBaseOverride baseOverride; + bool flag = false; // Passed up some rules union { V3Number* nump; string* strp; diff --git a/src/V3ParseSym.h b/src/V3ParseSym.h index 1f24cd76c..d1911a8bd 100644 --- a/src/V3ParseSym.h +++ b/src/V3ParseSym.h @@ -130,13 +130,6 @@ public: UASSERT_OBJ(!m_sympStack.empty(), nodep, "symbol stack underflow"); m_symCurrentp = m_sympStack.back(); } - AstNodeModule* findTopNodeModule(FileLine* fl, bool requireNoneNull = true) { - for (VSymEnt* const symp : vlstd::reverse_view(m_sympStack)) { - if (AstNodeModule* const modp = VN_CAST(symp->nodep(), NodeModule)) return modp; - } - if (requireNoneNull) fl->v3fatalSrc("fail to find current module"); - return nullptr; - } void showUpward() { // LCOV_EXCL_START UINFO(1, "ParseSym Stack:\n"); for (VSymEnt* const symp : vlstd::reverse_view(m_sympStack)) { diff --git a/src/verilog.y b/src/verilog.y index 1a4940496..5c69afffb 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -1379,6 +1379,7 @@ module_declaration: // ==IEEE: module_declaration modFront importsAndParametersE portsStarE ';' /*cont*/ module_itemListE yENDMODULE endLabelE { $1->modTrace(GRAMMARP->allTracingOn($1->fileline())); // Stash for implicit wires, etc + $1->hasParameterList($2); if ($2) $1->addStmtsp($2); if ($3) $1->addStmtsp($3); if ($5) $1->addStmtsp($5); @@ -1414,8 +1415,11 @@ modFront: importsAndParametersE: // IEEE: common part of module_declaration, interface_declaration, program_declaration // // { package_import_declaration } [ parameter_port_list ] - parameter_port_listE { $$ = $1; } - | package_import_declarationList parameter_port_listE { $$ = addNextNull($1, $2); } + parameter_port_listE + { $$ = $1; $$ = $1; } // hasParameterList + | package_import_declarationList parameter_port_listE + { $$ = addNextNull($1, $2); + $$ = $2; } // hasParameterList ; udpFront: @@ -1460,17 +1464,17 @@ parameter_value_assignmentClass: // IEEE: parameter_value_assignment (for ; parameter_port_listE: // IEEE: parameter_port_list + empty == parameter_value_assignment - /* empty */ { $$ = nullptr; } + /* empty */ { $$ = nullptr; $$ = false; } // hasParameterList | '#' '(' ')' { $$ = nullptr; - SYMP->findTopNodeModule($1)->hasParameterList(true); } + $$ = true; } // hasParameterList // // IEEE: '#' '(' list_of_param_assignments { ',' parameter_port_declaration } ')' // // IEEE: '#' '(' parameter_port_declaration { ',' parameter_port_declaration } ')' // // Can't just do that as "," conflicts with between vars and between stmts, so // // split into pre-comma and post-comma parts | '#' '(' { VARRESET_LIST(GPARAM); - SYMP->findTopNodeModule($1)->hasParameterList(true); GRAMMARP->m_pinAnsi = true; } /*cont*/ paramPortDeclOrArgList ')' { $$ = $4; + $$ = true; // hasParameterList VARRESET_NONLIST(UNKNOWN); GRAMMARP->m_pinAnsi = false; } // // Note legal to start with "a=b" with no parameter statement @@ -1685,6 +1689,7 @@ interface_declaration: // IEEE: interface_declaration + interface_nonan { if ($2) $1->addStmtsp($2); if ($3) $1->addStmtsp($3); if ($5) $1->addStmtsp($5); + $1->hasParameterList($2); SYMP->popScope($1); } | yEXTERN intFront parameter_port_listE portsStarE ';' { BBUNSUP($1, "Unsupported: extern interface"); } @@ -1769,6 +1774,7 @@ program_declaration: // IEEE: program_declaration + program_nonansi_h pgmFront parameter_port_listE portsStarE ';' /*cont*/ program_itemListE yENDPROGRAM endLabelE { $1->modTrace(GRAMMARP->allTracingOn($1->fileline())); // Stash for implicit wires, etc + $1->hasParameterList($2); if ($2) $1->addStmtsp($2); if ($3) $1->addStmtsp($3); if ($5) $1->addStmtsp($5); @@ -7307,6 +7313,7 @@ class_declaration: // ==IEEE: part of class_declaration // // new class scope correct via classFront classFront parameter_port_listE classExtendsE classImplementsE ';' /*mid*/ { // Allow resolving types declared in base extends class + $1->hasParameterList($2); if ($3) SYMP->importExtends($3); } /*cont*/ class_itemListEnd endLabelE