-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,30 @@ void ValidateParsedProgram::postorder(const IR::P4Table* t) { | |
} | ||
} | ||
|
||
void ValidateParsedProgram::distinctParameters( | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jnfoster
Contributor
|
||
const IR::TypeParameters* typeParams, | ||
const IR::ParameterList* apply, | ||
const IR::ParameterList* constr) { | ||
std::map<cstring, const IR::Node*> found; | ||
|
||
for (auto p : *typeParams->parameters) | ||
found.emplace(p->getName(), p); | ||
for (auto p : *apply->parameters) { | ||
auto it = found.find(p->getName()); | ||
if (it != found.end()) | ||
::error("Duplicated parameter name: %1% and %2%", | ||
it->second, p); | ||
else | ||
found.emplace(p->getName(), p); | ||
} | ||
for (auto p : *constr->parameters) { | ||
auto it = found.find(p->getName()); | ||
if (it != found.end()) | ||
::error("Duplicated parameter name: %1% and %2%", | ||
it->second, p); | ||
} | ||
} | ||
|
||
void ValidateParsedProgram::postorder(const IR::ConstructorCallExpression* expression) { | ||
auto inAction = findContext<IR::P4Action>(); | ||
if (inAction != nullptr) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright 2017 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. | ||
*/ | ||
|
||
control c(bit<32> p)(bool p) { | ||
apply {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright 2017 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. | ||
*/ | ||
|
||
control MyIngress<p>(inout bit<32> p) { | ||
apply {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright 2017 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. | ||
*/ | ||
|
||
control MyIngress<p>(inout bit<32> x)(bit<32> p) { | ||
apply {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright 2017 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. | ||
*/ | ||
|
||
control MyIngress<p>(inout bit<32> p)(bit<32> p) { | ||
apply {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
control c(bit<32> p)(bool p) { | ||
apply { | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
../testdata/p4_16_errors/dup-param.p4(17): error: Duplicated parameter name: p and p | ||
control c(bit<32> p)(bool p) { | ||
^ | ||
../testdata/p4_16_errors/dup-param.p4(17) | ||
control c(bit<32> p)(bool p) { | ||
^ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
control MyIngress<p>(inout bit<32> p) { | ||
apply { | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
../testdata/p4_16_errors/dup-param1.p4(17): error: Duplicated parameter name: p and p | ||
control MyIngress<p>(inout bit<32> p) { | ||
^ | ||
../testdata/p4_16_errors/dup-param1.p4(17) | ||
control MyIngress<p>(inout bit<32> p) { | ||
^ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
control MyIngress<p>(inout bit<32> x)(bit<32> p) { | ||
apply { | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
../testdata/p4_16_errors/dup-param2.p4(17): error: Duplicated parameter name: p and p | ||
control MyIngress<p>(inout bit<32> x)(bit<32> p) { | ||
^ | ||
../testdata/p4_16_errors/dup-param2.p4(17) | ||
control MyIngress<p>(inout bit<32> x)(bit<32> p) { | ||
^ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
control MyIngress<p>(inout bit<32> p)(bit<32> p) { | ||
apply { | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
../testdata/p4_16_errors/dup-param3.p4(17): error: Duplicated parameter name: p and p | ||
control MyIngress<p>(inout bit<32> p)(bit<32> p) { | ||
^ | ||
../testdata/p4_16_errors/dup-param3.p4(17) | ||
control MyIngress<p>(inout bit<32> p)(bit<32> p) { | ||
^ | ||
../testdata/p4_16_errors/dup-param3.p4(17): error: Duplicated parameter name: p and p | ||
control MyIngress<p>(inout bit<32> p)(bit<32> p) { | ||
^ | ||
../testdata/p4_16_errors/dup-param3.p4(17) | ||
control MyIngress<p>(inout bit<32> p)(bit<32> p) { | ||
^ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
Copyright 2017 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. | ||
*/ | ||
|
||
header H {} | ||
|
||
control MyIngress(inout H p) { | ||
bit<8> p = 0; | ||
apply { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
header H { | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
header H { | ||
} | ||
|
||
control MyIngress(inout H p) { | ||
bit<8> p = 0; | ||
apply { | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
../testdata/p4_16_samples/shadow3.p4(20): warning: p shadows p | ||
bit<8> p = 0; | ||
^ | ||
../testdata/p4_16_samples/shadow3.p4(19) | ||
control MyIngress(inout H p) { | ||
^ | ||
warning: Program does not contain a `main' module |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#include <core.p4> | ||
|
||
control c(out bool x) { | ||
bit<32> x; | ||
table t1() { | ||
key = { | ||
x: exact; | ||
|
@mbudiu-vmw this method looks great, but it appears to be dead code. I've confirmed with Cole and Han that if we have duplicate parameters the error comes from index_vector.h ("Duplicates declaration") and not this code. Did you mean to invoke it somewhere?
Also, is it missing the analogous reasoning for type parameters? Unless there is some checking being done elsewhere, it seems like those could have duplicates too...