diff --git a/testdata/p4_16_errors/loop3-err.p4 b/testdata/p4_16_errors/loop3-err.p4 new file mode 100644 index 0000000000..f04dd3081d --- /dev/null +++ b/testdata/p4_16_errors/loop3-err.p4 @@ -0,0 +1,91 @@ +/* +Copyright 2024 Andy Fingerhut + +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. +*/ + +#include +#include + +header ethernet_t { + bit<48> dstAddr; + bit<48> srcAddr; + bit<16> etherType; +} + +struct metadata_t { +} + +struct headers_t { + ethernet_t ethernet; +} + +parser parserImpl(packet_in packet, + out headers_t hdr, + inout metadata_t meta, + inout standard_metadata_t stdmeta) +{ + state start { + packet.extract(hdr.ethernet); + transition accept; + } +} + +control ingressImpl(inout headers_t hdr, + inout metadata_t meta, + inout standard_metadata_t stdmeta) +{ + bit<8> n = 0; + bit<8> i = 20; + apply { + for (i in 1..6) { + n = n + i; + } + hdr.ethernet.srcAddr[15:8] = n; + hdr.ethernet.srcAddr[7:0] = i; + stdmeta.egress_spec = 1; + } +} + +control egressImpl(inout headers_t hdr, + inout metadata_t meta, + inout standard_metadata_t stdmeta) +{ + apply { + } +} + +control deparserImpl(packet_out packet, + in headers_t hdr) +{ + apply { + packet.emit(hdr.ethernet); + } +} + +control verifyChecksum(inout headers_t hdr, inout metadata_t meta) { + apply { + } +} + +control updateChecksum(inout headers_t hdr, inout metadata_t meta) { + apply { + } +} + +V1Switch(parserImpl(), + verifyChecksum(), + ingressImpl(), + egressImpl(), + updateChecksum(), + deparserImpl()) main; diff --git a/testdata/p4_16_errors_outputs/loop3-err.p4-stderr b/testdata/p4_16_errors_outputs/loop3-err.p4-stderr new file mode 100644 index 0000000000..1110c83c6a --- /dev/null +++ b/testdata/p4_16_errors_outputs/loop3-err.p4-stderr @@ -0,0 +1,4 @@ +loop3-err.p4(51):syntax error, unexpected IN + for (i in + ^^ +[--Werror=overlimit] error: 1 errors encountered, aborting compilation