Fix crash when super.new() called without a base class (#6772)

This commit is contained in:
Matthew Ballance 2025-12-06 15:08:51 -08:00 committed by GitHub
parent 040484cc3f
commit 0e03ab2a57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 1 deletions

View File

@ -4851,7 +4851,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
iterateChildren(nodep);
if (isNew) {
const AstClassExtends* const classExtendsp = VN_AS(m_modp, Class)->extendsp();
if (m_explicitSuperNewp && !m_explicitSuperNewp->isImplicit()
if (m_explicitSuperNewp && !m_explicitSuperNewp->isImplicit() && classExtendsp
&& classExtendsp->argsp()) {
m_explicitSuperNewp->v3error(
"Explicit super.new not allowed with class "

View File

@ -0,0 +1,5 @@
%Error: t/t_class_super_new_noextend_bad.v:10:12: 'super' used on non-extended class (IEEE 1800-2023 8.15)
10 | super.new();
| ^
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
%Error: Exiting due to

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2025 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('linter')
test.lint(fails=True, expect_filename=test.golden_filename)
test.passes()

View File

@ -0,0 +1,12 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2025 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
//
class Cls;
function new();
super.new(); // Bad - no extends
endfunction
endclass