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.
Do not print confusing warning when a parser state contains an assign…
…ment to an l-value slice (p4lang#4948) * Do not print confusing warning when a parser state contains an assignment to an l-value slice Signed-off-by: Kyle Cripps <[email protected]> * Add additional test case Signed-off-by: Kyle Cripps <[email protected]> * rename test Signed-off-by: Kyle Cripps <[email protected]> * Add assertion for AbstractSlice Signed-off-by: Kyle Cripps <[email protected]> --------- Signed-off-by: Kyle Cripps <[email protected]>
- Loading branch information
Showing
23 changed files
with
289 additions
and
3 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
12 changes: 12 additions & 0 deletions
12
testdata/p4_16_samples/parser-unroll-uninitialized-slice-read.p4
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,12 @@ | ||
#include <core.p4> | ||
|
||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
state start { | ||
g = f[3:0]; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out bit<8> f, out bit<4> g); | ||
package top(simple e); | ||
top(p()) main; |
16 changes: 16 additions & 0 deletions
16
testdata/p4_16_samples/parser-unroll-uninitialized-slice-write.p4
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,16 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<8> f; | ||
} | ||
|
||
parser p(packet_in packet, out S s) { | ||
state start { | ||
s.f[3:0] = 2; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out S s); | ||
package top(simple e); | ||
top(p()) main; |
12 changes: 12 additions & 0 deletions
12
testdata/p4_16_samples_outputs/parser-unroll-uninitialized-slice-read-first.p4
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,12 @@ | ||
#include <core.p4> | ||
|
||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
state start { | ||
g = f[3:0]; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out bit<8> f, out bit<4> g); | ||
package top(simple e); | ||
top(p()) main; |
12 changes: 12 additions & 0 deletions
12
testdata/p4_16_samples_outputs/parser-unroll-uninitialized-slice-read-frontend.p4
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,12 @@ | ||
#include <core.p4> | ||
|
||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
state start { | ||
g = f[3:0]; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out bit<8> f, out bit<4> g); | ||
package top(simple e); | ||
top(p()) main; |
12 changes: 12 additions & 0 deletions
12
testdata/p4_16_samples_outputs/parser-unroll-uninitialized-slice-read-midend.p4
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,12 @@ | ||
#include <core.p4> | ||
|
||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
state start { | ||
g = f[3:0]; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out bit<8> f, out bit<4> g); | ||
package top(simple e); | ||
top(p()) main; |
12 changes: 12 additions & 0 deletions
12
testdata/p4_16_samples_outputs/parser-unroll-uninitialized-slice-read.p4
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,12 @@ | ||
#include <core.p4> | ||
|
||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
state start { | ||
g = f[3:0]; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out bit<8> f, out bit<4> g); | ||
package top(simple e); | ||
top(p()) main; |
9 changes: 9 additions & 0 deletions
9
testdata/p4_16_samples_outputs/parser-unroll-uninitialized-slice-read.p4-stderr
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,9 @@ | ||
parser-unroll-uninitialized-slice-read.p4(5): [--Wwarn=uninitialized_use] warning: f may be uninitialized | ||
g = f[3:0]; | ||
^ | ||
parser-unroll-uninitialized-slice-read.p4(3): [--Wwarn=uninitialized_out_param] warning: out parameter 'f' may be uninitialized when 'p' terminates | ||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
^ | ||
parser-unroll-uninitialized-slice-read.p4(3) | ||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
^ |
16 changes: 16 additions & 0 deletions
16
testdata/p4_16_samples_outputs/parser-unroll-uninitialized-slice-write-first.p4
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,16 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<8> f; | ||
} | ||
|
||
parser p(packet_in packet, out S s) { | ||
state start { | ||
s.f[3:0] = 4w2; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out S s); | ||
package top(simple e); | ||
top(p()) main; |
16 changes: 16 additions & 0 deletions
16
testdata/p4_16_samples_outputs/parser-unroll-uninitialized-slice-write-frontend.p4
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,16 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<8> f; | ||
} | ||
|
||
parser p(packet_in packet, out S s) { | ||
state start { | ||
s.f[3:0] = 4w2; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out S s); | ||
package top(simple e); | ||
top(p()) main; |
16 changes: 16 additions & 0 deletions
16
testdata/p4_16_samples_outputs/parser-unroll-uninitialized-slice-write-midend.p4
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,16 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<8> f; | ||
} | ||
|
||
parser p(packet_in packet, out S s) { | ||
state start { | ||
s.f[3:0] = 4w2; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out S s); | ||
package top(simple e); | ||
top(p()) main; |
16 changes: 16 additions & 0 deletions
16
testdata/p4_16_samples_outputs/parser-unroll-uninitialized-slice-write.p4
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,16 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<8> f; | ||
} | ||
|
||
parser p(packet_in packet, out S s) { | ||
state start { | ||
s.f[3:0] = 2; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out S s); | ||
package top(simple e); | ||
top(p()) main; |
3 changes: 3 additions & 0 deletions
3
testdata/p4_16_samples_outputs/parser-unroll-uninitialized-slice-write.p4-stderr
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 @@ | ||
parser-unroll-uninitialized-slice-write.p4(9): [--Wwarn=uninitialized_use] warning: s.f may be uninitialized | ||
s.f[3:0] = 2; | ||
^^^ |
12 changes: 12 additions & 0 deletions
12
testdata/p4_16_samples_outputs/parser-unroll/parser-unroll-uninitialized-slice-read-first.p4
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,12 @@ | ||
#include <core.p4> | ||
|
||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
state start { | ||
g = f[3:0]; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out bit<8> f, out bit<4> g); | ||
package top(simple e); | ||
top(p()) main; |
12 changes: 12 additions & 0 deletions
12
...ta/p4_16_samples_outputs/parser-unroll/parser-unroll-uninitialized-slice-read-frontend.p4
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,12 @@ | ||
#include <core.p4> | ||
|
||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
state start { | ||
g = f[3:0]; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out bit<8> f, out bit<4> g); | ||
package top(simple e); | ||
top(p()) main; |
12 changes: 12 additions & 0 deletions
12
...data/p4_16_samples_outputs/parser-unroll/parser-unroll-uninitialized-slice-read-midend.p4
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,12 @@ | ||
#include <core.p4> | ||
|
||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
state start { | ||
g = f[3:0]; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out bit<8> f, out bit<4> g); | ||
package top(simple e); | ||
top(p()) main; |
12 changes: 12 additions & 0 deletions
12
testdata/p4_16_samples_outputs/parser-unroll/parser-unroll-uninitialized-slice-read.p4
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,12 @@ | ||
#include <core.p4> | ||
|
||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
state start { | ||
g = f[3:0]; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out bit<8> f, out bit<4> g); | ||
package top(simple e); | ||
top(p()) main; |
12 changes: 12 additions & 0 deletions
12
...data/p4_16_samples_outputs/parser-unroll/parser-unroll-uninitialized-slice-read.p4-stderr
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,12 @@ | ||
parser-unroll-uninitialized-slice-read.p4(5): [--Wwarn=uninitialized_use] warning: f may be uninitialized | ||
g = f[3:0]; | ||
^ | ||
parser-unroll-uninitialized-slice-read.p4(3): [--Wwarn=uninitialized_out_param] warning: out parameter 'f' may be uninitialized when 'p' terminates | ||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
^ | ||
parser-unroll-uninitialized-slice-read.p4(3) | ||
parser p(packet_in packet, out bit<8> f, out bit<4> g) { | ||
^ | ||
parser-unroll-uninitialized-slice-read.p4(5): [--Wwarn=ignore-prop] warning: Result of 'g = f[3:0]' is not defined: Error: Uninitialized | ||
g = f[3:0]; | ||
^ |
16 changes: 16 additions & 0 deletions
16
...data/p4_16_samples_outputs/parser-unroll/parser-unroll-uninitialized-slice-write-first.p4
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,16 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<8> f; | ||
} | ||
|
||
parser p(packet_in packet, out S s) { | ||
state start { | ||
s.f[3:0] = 4w2; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out S s); | ||
package top(simple e); | ||
top(p()) main; |
16 changes: 16 additions & 0 deletions
16
...a/p4_16_samples_outputs/parser-unroll/parser-unroll-uninitialized-slice-write-frontend.p4
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,16 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<8> f; | ||
} | ||
|
||
parser p(packet_in packet, out S s) { | ||
state start { | ||
s.f[3:0] = 4w2; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out S s); | ||
package top(simple e); | ||
top(p()) main; |
16 changes: 16 additions & 0 deletions
16
...ata/p4_16_samples_outputs/parser-unroll/parser-unroll-uninitialized-slice-write-midend.p4
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,16 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<8> f; | ||
} | ||
|
||
parser p(packet_in packet, out S s) { | ||
state start { | ||
s.f[3:0] = 4w2; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out S s); | ||
package top(simple e); | ||
top(p()) main; |
16 changes: 16 additions & 0 deletions
16
testdata/p4_16_samples_outputs/parser-unroll/parser-unroll-uninitialized-slice-write.p4
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,16 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<8> f; | ||
} | ||
|
||
parser p(packet_in packet, out S s) { | ||
state start { | ||
s.f[3:0] = 2; | ||
transition accept; | ||
} | ||
} | ||
|
||
parser simple(packet_in packet, out S s); | ||
package top(simple e); | ||
top(p()) main; |
3 changes: 3 additions & 0 deletions
3
...ata/p4_16_samples_outputs/parser-unroll/parser-unroll-uninitialized-slice-write.p4-stderr
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 @@ | ||
parser-unroll-uninitialized-slice-write.p4(9): [--Wwarn=uninitialized_use] warning: s.f may be uninitialized | ||
s.f[3:0] = 2; | ||
^^^ |