forked from p4lang/p4c
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forbid use of .lastIndex outside of parsers (p4lang#3523)
Signed-off-by: Mihai Budiu <[email protected]> Signed-off-by: Mihai Budiu <[email protected]>
- Loading branch information
Mihai Budiu
authored
Sep 10, 2022
1 parent
c5b9873
commit 14c56cf
Showing
7 changed files
with
37 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
issue1853.p4(26): [--Werror=type-error] error: hdr.value.last: 'last' and 'next' for stacks can only be used in a parser | ||
issue1853.p4(26): [--Werror=type-error] error: hdr.value.last: 'last', and 'next' for stacks can only be used in a parser | ||
modify_field(value[last].bos, 0); | ||
^^^^^^^^^^^ |
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,11 @@ | ||
header h { | ||
bit field; | ||
}; | ||
|
||
struct s { | ||
h[2] field; | ||
}; | ||
|
||
action a(in s v) { | ||
bit<32> t = v.field.lastIndex; | ||
} |
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,11 @@ | ||
header h { | ||
bit<1> field; | ||
} | ||
|
||
struct s { | ||
h[2] field; | ||
} | ||
|
||
action a(in s v) { | ||
bit<32> t = v.field.lastIndex; | ||
} |
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,3 @@ | ||
issue3522.p4(10): [--Werror=type-error] error: v.field.lastIndex: 'lastIndex' for stacks can only be used in a parser | ||
bit<32> t = v.field.lastIndex; | ||
^^^^^^^^^^^^^^^^^ |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
next.p4(24): [--Werror=type-error] error: stack.last: 'last' and 'next' for stacks can only be used in a parser | ||
next.p4(24): [--Werror=type-error] error: stack.last: 'last', and 'next' for stacks can only be used in a parser | ||
stack.last = { 10 }; | ||
^^^^^^^^^^ |
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