-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Emit diagnostic when a declaration is not allowed in the region…
… it resides (#224) * Feat: Emit diagnostic when a declaration is not allowed in the region it resides * Disallow shared variables in block contexts; allow them elsewhere * Allow signals in packages * Refactor: Use AnyEntKind enum instead of DeclarativeContext * Add copyright header
- Loading branch information
1 parent
c86d370
commit f9d0ee9
Showing
8 changed files
with
185 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at http://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2023, Olof Kraigher [email protected] | ||
use crate::analysis::tests::{check_diagnostics, LibraryBuilder}; | ||
use crate::Diagnostic; | ||
|
||
#[test] | ||
pub fn declaration_not_allowed_everywhere() { | ||
let mut builder = LibraryBuilder::new(); | ||
let code = builder.code( | ||
"libname", | ||
"\ | ||
entity ent is | ||
end entity; | ||
architecture arch of ent is | ||
function my_func return natural is | ||
signal x : bit; | ||
begin | ||
end my_func; | ||
begin | ||
my_block : block | ||
variable y: natural; | ||
begin | ||
end block my_block; | ||
end architecture; | ||
", | ||
); | ||
check_diagnostics( | ||
builder.analyze(), | ||
vec![ | ||
Diagnostic::error( | ||
code.s1("signal x : bit;"), | ||
"signal declaration not allowed here", | ||
), | ||
Diagnostic::error( | ||
code.s1("variable y: natural;"), | ||
"variable declaration not allowed here", | ||
), | ||
], | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters