Skip to content

Commit

Permalink
Rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
mbudiu-vmw committed Oct 8, 2019
1 parent 41dda85 commit 48a140f
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions p4-16/spec/P4-16-spec.mdk
Original file line number Diff line number Diff line change
Expand Up @@ -3053,7 +3053,7 @@ automatic casting from an `enum` to its fixed-width (signed or unsigned) integer
bit<8> x = E.e2; // sets x to 1 (E.e2 is automatically casted to bit<8>)

E a = E.e2
bit<8> y = a << 3; // sets y to 8 (a is automatically casted to bit<8> and then shifted)
bit<8> y = a << 3; // sets y to 8 (a is automatically casted to bit<8> and then shifted)
~ End P4Example

Automatic casting from an underlying fixed-width type to an enum is *not* supported.
Expand All @@ -3063,21 +3063,21 @@ enum bit<8> E1 {
e1 = 0, e2 = 1, e3 = 2
}

enum bit<8> E1 {
enum bit<8> E2 {
e1 = 10, e2 = 11, e3 = 12
}
E1 a = E1.e1;
E2 b = E2.e2;

a = b; // Error: b is automatically casted to bit<8>,
// but bit<8> cannot be automatically casted to E1

a = (E1) b; // OK

a = E1.e1 + 1; // Error: E.e1 is automatically casted to bit<8>,
// and the right-hand expression has
// the type bit<8>, which cannot be casted to E automatically.

a = (E1)(E1.e1 + 1); // Final explicit casting makes the assinment legal

a = E1.e1 + E1.e2; // Error: both arguments to the addition are automatically
Expand All @@ -3094,7 +3094,7 @@ E1 a = E1.e1;
E2 b = E2.e2;
bit<8> c;

if (a > b) { // Warning: two automatic and different casts to bit<8>. Otherwise OK
if (a > b) { // Potential warning: two automatic and different casts to bit<8>.
...
}

Expand All @@ -3111,7 +3111,7 @@ E e = (E) x; // sets e to an unnamed value
~ End P4Example

sets `e` to an unnamed value, since there is no symbol corresponding to the
fixed-width unsigned integer value `5`.
fixed-width unsigned integer value `5`.

For example, in the following code, the `else` clause of the `if/else if/else`
block can be reached even though the matches on `x` are complete with respect
Expand Down Expand Up @@ -7238,13 +7238,17 @@ The P4 compiler should provide:
| | | restrictions on arguments to calls, and modified precedence of |
| | | bitwise operators. |
|-----|-----|-----|
| 1.2.0 | April TBD, 2019 | Added error `ParserInvalidArgument`. |
| 1.2.0 | October, 2019 | Added error `ParserInvalidArgument`, order of `const` entries, |
| | | header size methods, 1-bit signed values, signed bit slices, empty |
| | | tuples, `@deprecated` annotation, free-form annotations, `int` type |
| | | `table.apply().miss`, `string` type. |
|-----|-----|-----|

## Summary of changes made in version 1.2.0

* Added `table.apply().miss`
* Added `string` type (Section [#sec-string].)
* Added `table.apply().miss` (Section [#sec-invoke-mau]).
* Added `string` type (Section [#sec-string]).
* Implicit casts from enum values (Section [#sec-enum-exprs]).
* Allow 1-bit signed values
* Define the type of bit slices from signed and unsigned values to be unsigned.
* Constrain `default` label position for `switch` statements.
Expand All @@ -7253,7 +7257,7 @@ The P4 compiler should provide:
* Relaxed the structure of annotation bodies.
* Removed the `@pkginfo` annotation. This is defined by the P4Runtime
specification.
* Added `int` type (Section [#sec-infinite-precision-integers].)
* Added `int` type (Section [#sec-infinite-precision-integers]).
* Added error `ParserInvalidArgument` (Sections
[#sec-packet-extract-two], [#sec-skip-bits]).
* Clarify the significance of order of entries in `const entries`
Expand Down

0 comments on commit 48a140f

Please sign in to comment.