Merge pull request #857 from larsclausen/import-hier-fail
Don't allow access to imported identifiers through hierarchical names
This commit is contained in:
commit
7b105a696d
|
|
@ -0,0 +1,24 @@
|
|||
// Check that imported identifiers can't be accessed through hierarchical names.
|
||||
|
||||
package P;
|
||||
integer x;
|
||||
endpackage
|
||||
|
||||
module M;
|
||||
import P::x;
|
||||
integer y;
|
||||
always_comb y = x;
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
M m ();
|
||||
|
||||
initial begin
|
||||
integer y;
|
||||
y = m.x; // This should fail. Imported identifiers are not visible through
|
||||
// hierarchical names.
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Check that imported identifiers can't be accessed through hierarchical names.
|
||||
|
||||
package P;
|
||||
integer x;
|
||||
endpackage
|
||||
|
||||
module M;
|
||||
import P::*;
|
||||
integer y;
|
||||
always_comb y = x;
|
||||
endmodule
|
||||
|
||||
module test;
|
||||
|
||||
M m ();
|
||||
|
||||
initial begin
|
||||
integer y;
|
||||
y = m.x; // This should fail. Imported identifiers are not visible through
|
||||
// hierarchical names.
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
// Check that imported identifiers can't be accessed through hierarchical names.
|
||||
|
||||
package P;
|
||||
integer x;
|
||||
endpackage
|
||||
|
||||
module test;
|
||||
|
||||
initial begin : outer
|
||||
integer y;
|
||||
begin: inner
|
||||
import P::x;
|
||||
y = x;
|
||||
end
|
||||
y = inner.x; // This should fail. Imported identifiers are not visible
|
||||
// through hierarchical names.
|
||||
$display("FAILED");
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -656,6 +656,9 @@ sv_foreach8 normal,-g2009 ivltests gold=sv_foreach8.gold
|
|||
sv_foreach_fail1 CE,-g2009 ivltests
|
||||
sv_immediate_assert normal,-g2009 ivltests gold=sv_immediate_assert.gold
|
||||
sv_immediate_assume normal,-g2009 ivltests gold=sv_immediate_assume.gold
|
||||
sv_import_hier_fail1 CE,-g2005-sv ivltests
|
||||
sv_import_hier_fail2 CE,-g2005-sv ivltests
|
||||
sv_import_hier_fail3 CE,-g2005-sv ivltests
|
||||
sv_macro normal,-g2009 ivltests
|
||||
sv_macro2 normal,-g2009 ivltests gold=sv_macro2.gold
|
||||
sv_macro3a normal,-g2009 ivltests gold=sv_macro3.gold
|
||||
|
|
|
|||
|
|
@ -202,11 +202,6 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
}
|
||||
}
|
||||
|
||||
if (NetScope*import_scope = scope->find_import(des, path_tail.name)) {
|
||||
scope = import_scope;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Could not find an object. Maybe this is a child scope name? If
|
||||
// so, evaluate the path components to find the exact scope this
|
||||
// refers to. This item might be:
|
||||
|
|
@ -234,6 +229,12 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
if (prefix_scope)
|
||||
break;
|
||||
|
||||
// Imports are not visible through hierachical names
|
||||
if (NetScope*import_scope = scope->find_import(des, path_tail.name)) {
|
||||
scope = import_scope;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Special case: We can match the module name of a parent
|
||||
// module. That means if the current scope is a module of type
|
||||
// "mod", then "mod" matches the current scope. This is fairly
|
||||
|
|
|
|||
Loading…
Reference in New Issue