p4c
p4c copied to clipboard
switch allowing duplicated cases for switch on bit<4>
Take:
#include <core.p4>
control c(in bit<4> a)
{
apply {
switch (a) {
4w0: {}
4w1: {} // { dg-note "" }
4w1: {} // { dg-error "" }
}
}
}
control ct(in bit<4> a);
package pt(ct t);
pt(c()) main;
This should fail as 4w1 is repeated. The langauge spec is clear here even:
12.7.3. Notes common to all switch statements
It is a compile-time error if two labels of a switch statement equal each other.