-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow constant-folding of arbitrary-precision integer casts (#4325)
* Allow constant-folding of arbitrary-precision integer casts * Update reference outputs to match fixes in constant folding * Add one more test, including negative value
- Loading branch information
Showing
10 changed files
with
45 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const bit<4> a = 0b0101; | ||
const int b = (int)a; // 5 | ||
const bit<7> c = (bit<7>)b; // 5 | ||
|
||
const int<4> d = -1; | ||
const int e = (int)d; // -1 | ||
const bit<7> f = (bit<7>)e; // 0b1111111 = 127 | ||
const int<7> g = (int<7>)e; // 0b1111111 = -1 | ||
const int h = (int)g; // -1 |
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,8 @@ | ||
const bit<4> a = 4w0b101; | ||
const int b = 0b101; | ||
const bit<7> c = 7w0b101; | ||
const int<4> d = -4s1; | ||
const int e = -1; | ||
const bit<7> f = 7w127; | ||
const int<7> g = -7s1; | ||
const int h = -1; |
Empty file.
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,8 @@ | ||
const bit<4> a = 0b101; | ||
const int b = (int)a; | ||
const bit<7> c = (bit<7>)b; | ||
const int<4> d = -1; | ||
const int e = (int)d; | ||
const bit<7> f = (bit<7>)e; | ||
const int<7> g = (int<7>)e; | ||
const int h = (int)g; |
4 changes: 4 additions & 0 deletions
4
testdata/p4_16_samples_outputs/constant-fold-infint.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,4 @@ | ||
constant-fold-infint.p4(6): [--Wwarn=mismatch] warning: -7w1: negative value with unsigned type | ||
const int e = (int)d; // -1 | ||
^^^^^^ | ||
[--Wwarn=missing] warning: Program does not contain a `main' module |
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