-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comparisons of list expressions, structure-valued expressions, tuples…
… and structs #3057 * I corrected the code so that the compiler bug does not occur when comparing structures of unknown type, but to report an error * I enabled a comparison between the structure/list expression so that the cast can be put on either side. Before this change, if the cast was on the right side of the comparison operator error was reported. * Added tests which verify the above
- Loading branch information
1 parent
e893e65
commit e054f2b
Showing
12 changed files
with
148 additions
and
4 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,17 @@ | ||
struct S { | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
control proto(); | ||
package top(proto _p); | ||
control c() { | ||
apply { | ||
bool b1 = { 1, 2 } == { 1, 2 }; | ||
bool b2 = {a = 32w1,b = 32w2} == {a = 32w1,b = 32w2}; | ||
bool b2_ = {a = 1,b = 2} == {a = 1,b = 2}; | ||
} | ||
} | ||
|
||
top(c()) main; | ||
|
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,17 @@ | ||
struct S { | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
control proto(); | ||
package top(proto _p); | ||
control c() { | ||
apply { | ||
bool b1 = { 1, 2 } == { 1, 2 }; | ||
bool b2 = {a = 32w1,b = 32w2} == {a = 32w1,b = 32w2}; | ||
bool b2_ = {a = 1,b = 2} == {a = 1,b = 2}; | ||
} | ||
} | ||
|
||
top(c()) main; | ||
|
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 @@ | ||
issue3057-1.p4(11): [--Werror=type-error] error: ==: cannot compare structure-valued expressions with unknown types | ||
bool b2 = {a = 32w1,b = 32w2} == {a = 32w1,b = 32w2}; | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
issue3057-1.p4(12): [--Werror=type-error] error: ==: cannot compare structure-valued expressions with unknown types | ||
bool b2_ = {a = 1,b = 2} == {a = 1,b = 2}; | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
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,35 @@ | ||
/* | ||
Copyright 2016 VMware, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
struct S { | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
|
||
control proto(); | ||
package top(proto _p); | ||
|
||
control c() { | ||
apply { | ||
|
||
bool b5 = (S) { a = 1, b = 2 } == { a = 1, b = 2 }; | ||
bool b5_ = { a = 1, b = 2 } == (S) { a = 1, b = 2 }; | ||
|
||
} | ||
} | ||
|
||
top(c()) main; |
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 @@ | ||
struct S { | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
control proto(); | ||
package top(proto _p); | ||
control c() { | ||
apply { | ||
bool b5 = (S){a = 32w1,b = 32w2} == (S){a = 32w1,b = 32w2}; | ||
bool b5_ = (S){a = 32w1,b = 32w2} == (S){a = 32w1,b = 32w2}; | ||
} | ||
} | ||
|
||
top(c()) main; | ||
|
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,14 @@ | ||
struct S { | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
control proto(); | ||
package top(proto _p); | ||
control c() { | ||
apply { | ||
} | ||
} | ||
|
||
top(c()) main; | ||
|
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,14 @@ | ||
struct S { | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
control proto(); | ||
package top(proto _p); | ||
control c() { | ||
apply { | ||
} | ||
} | ||
|
||
top(c()) main; | ||
|
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 @@ | ||
struct S { | ||
bit<32> a; | ||
bit<32> b; | ||
} | ||
|
||
control proto(); | ||
package top(proto _p); | ||
control c() { | ||
apply { | ||
bool b5 = (S){a = 1,b = 2} == {a = 1,b = 2}; | ||
bool b5_ = {a = 1,b = 2} == (S){a = 1,b = 2}; | ||
} | ||
} | ||
|
||
top(c()) main; | ||
|
Empty file.
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,3 @@ | ||
pkg_info { | ||
arch: "v1model" | ||
} |