Commit ff241115 by Zachary Snow

forbid bit-selects and part-selects of scalar struct fields

parent 814f9659
......@@ -32,6 +32,8 @@
* Non-positive integer size casts are now detected and forbidden
* Negative indices in struct pattern literals are now detected and forbidden
* Escaped vendor block comments in macro bodies are now tolerated
* Illegal bit-selects and part-selects of scalar struct fields are now detected
and forbidden, rather than yielding an internal assertion failure
### Bug Fixes
......
......@@ -386,6 +386,9 @@ convertSubExpr scopes (Range (Dot e x) NonIndexed rOuter) =
(UnknownType, orig')
else if structIsntReady subExprType then
(replaceInnerTypeRange NonIndexed rOuter' fieldType, orig')
else if null dims then
error $ "illegal access to range " ++ show (Range Nil NonIndexed rOuter)
++ " of " ++ show (Dot e x) ++ ", which has type " ++ show fieldType
else
(replaceInnerTypeRange NonIndexed rOuter' fieldType, undotted)
where
......@@ -408,6 +411,9 @@ convertSubExpr scopes (Range (Dot e x) mode (baseO, lenO)) =
(UnknownType, orig')
else if structIsntReady subExprType then
(replaceInnerTypeRange mode (baseO', lenO') fieldType, orig')
else if null dims then
error $ "illegal access to range " ++ show (Range Nil mode (baseO, lenO))
++ " of " ++ show (Dot e x) ++ ", which has type " ++ show fieldType
else
(replaceInnerTypeRange mode (baseO', lenO') fieldType, undotted)
where
......@@ -438,6 +444,9 @@ convertSubExpr scopes (Bit (Dot e x) i) =
(dropInnerTypeRange backupType, orig')
else if structIsntReady subExprType then
(dropInnerTypeRange fieldType, orig')
else if null dims then
error $ "illegal access to bit " ++ show i ++ " of " ++ show (Dot e x)
++ ", which has type " ++ show fieldType
else
(dropInnerTypeRange fieldType, Bit e' iFlat)
where
......
// pattern: illegal access to bit 0 of s\.x, which has type logic
module top;
struct packed {
logic x;
} s;
initial s.x[0] = 1;
endmodule
// pattern: illegal access to range \[0:0\] of s\.x, which has type logic
module top;
struct packed {
logic x;
} s;
initial s.x[0:0] = 1;
endmodule
// pattern: illegal access to range \[0\+:1\] of s\.x, which has type logic
module top;
struct packed {
logic x;
} s;
initial s.x[0+:1] = 1;
endmodule
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment