-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Allow implicit casts from serializable enums to their underlying type in action calls
- Loading branch information
Showing
13 changed files
with
175 additions
and
2 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
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,22 @@ | ||
#include <core.p4> | ||
|
||
enum bit<2> foo_t { A = 0, B = 1, C = 2, D = 3 } | ||
|
||
struct meta_t { | ||
bit<2> x; | ||
bit<6> y; | ||
} | ||
|
||
control c(inout meta_t m) { | ||
action set_x(foo_t v) { m.x = v; } | ||
|
||
table t { | ||
key = { m.y : exact; } | ||
actions = { set_x; } | ||
default_action = set_x(2w0); // not allowed to implicitly cast to serenum | ||
} | ||
|
||
apply { | ||
t.apply(); | ||
} | ||
} |
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,32 @@ | ||
#include <core.p4> | ||
|
||
enum bit<2> foo_t { | ||
A = 0, | ||
B = 1, | ||
C = 2, | ||
D = 3 | ||
} | ||
|
||
struct meta_t { | ||
bit<2> x; | ||
bit<6> y; | ||
} | ||
|
||
control c(inout meta_t m) { | ||
action set_x(foo_t v) { | ||
m.x = v; | ||
} | ||
table t { | ||
key = { | ||
m.y: exact; | ||
} | ||
actions = { | ||
set_x; | ||
} | ||
default_action = set_x(2w0); | ||
} | ||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
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,6 @@ | ||
serEnumImplCast.p4(16): [--Werror=type-error] error: '2w0': values of type 'bit<2>' cannot be implicitly cast to type 'foo_t' | ||
default_action = set_x(2w0); // not allowed to implicitly cast to serenum | ||
^^^ | ||
serEnumImplCast.p4(3) | ||
enum bit<2> foo_t { A = 0, B = 1, C = 2, D = 3 } | ||
^^^^^ |
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,22 @@ | ||
#include <core.p4> | ||
|
||
enum bit<2> foo_t { A = 0, B = 1, C = 2, D = 3 } | ||
|
||
struct meta_t { | ||
bit<2> x; | ||
bit<6> y; | ||
} | ||
|
||
control c(inout meta_t m) { | ||
action set_x(bit<2> v) { m.x = v; } | ||
|
||
table t { | ||
key = { m.y : exact; } | ||
actions = { set_x; } | ||
default_action = set_x(foo_t.A); | ||
} | ||
|
||
apply { | ||
t.apply(); | ||
} | ||
} |
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,32 @@ | ||
#include <core.p4> | ||
|
||
enum bit<2> foo_t { | ||
A = 2w0, | ||
B = 2w1, | ||
C = 2w2, | ||
D = 2w3 | ||
} | ||
|
||
struct meta_t { | ||
bit<2> x; | ||
bit<6> y; | ||
} | ||
|
||
control c(inout meta_t m) { | ||
action set_x(bit<2> v) { | ||
m.x = v; | ||
} | ||
table t { | ||
key = { | ||
m.y: exact @name("m.y"); | ||
} | ||
actions = { | ||
set_x(); | ||
} | ||
default_action = set_x(foo_t.A); | ||
} | ||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
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,7 @@ | ||
#include <core.p4> | ||
|
||
struct meta_t { | ||
bit<2> x; | ||
bit<6> y; | ||
} | ||
|
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,32 @@ | ||
#include <core.p4> | ||
|
||
enum bit<2> foo_t { | ||
A = 0, | ||
B = 1, | ||
C = 2, | ||
D = 3 | ||
} | ||
|
||
struct meta_t { | ||
bit<2> x; | ||
bit<6> y; | ||
} | ||
|
||
control c(inout meta_t m) { | ||
action set_x(bit<2> v) { | ||
m.x = v; | ||
} | ||
table t { | ||
key = { | ||
m.y: exact; | ||
} | ||
actions = { | ||
set_x; | ||
} | ||
default_action = set_x(foo_t.A); | ||
} | ||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
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 @@ | ||
[--Wwarn=missing] warning: Program does not contain a `main' module |