diff --git a/testdata/p4_16_errors/default-switch.p4 b/testdata/p4_16_errors/default-last-switch.p4 similarity index 100% rename from testdata/p4_16_errors/default-switch.p4 rename to testdata/p4_16_errors/default-last-switch.p4 diff --git a/testdata/p4_16_errors_outputs/default-switch.p4 b/testdata/p4_16_errors_outputs/default-last-switch.p4 similarity index 100% rename from testdata/p4_16_errors_outputs/default-switch.p4 rename to testdata/p4_16_errors_outputs/default-last-switch.p4 diff --git a/testdata/p4_16_errors_outputs/default-last-switch.p4-stderr b/testdata/p4_16_errors_outputs/default-last-switch.p4-stderr new file mode 100644 index 0000000000..67270e116a --- /dev/null +++ b/testdata/p4_16_errors_outputs/default-last-switch.p4-stderr @@ -0,0 +1,9 @@ +default-last-switch.p4(11): [--Werror=invalid] error: switch label b follows 'default' label, which is not allowed. + switch (t.apply().action_run) { + ^^^^^^ +default-last-switch.p4(13) + b: { return; } + ^ +default-last-switch.p4(12) + default: + ^^^^^^^ diff --git a/testdata/p4_16_errors_outputs/default-switch.p4-stderr b/testdata/p4_16_errors_outputs/default-switch.p4-stderr deleted file mode 100644 index 4367dc9199..0000000000 --- a/testdata/p4_16_errors_outputs/default-switch.p4-stderr +++ /dev/null @@ -1,9 +0,0 @@ -default-switch.p4(11): [--Werror=invalid] error: switch label b follows 'default' label, which is not allowed. - switch (t.apply().action_run) { - ^^^^^^ -default-switch.p4(13) - b: { return; } - ^ -default-switch.p4(12) - default: - ^^^^^^^ diff --git a/testdata/p4_16_samples/default-switch.p4 b/testdata/p4_16_samples/default-switch.p4 new file mode 100644 index 0000000000..91baf0d8df --- /dev/null +++ b/testdata/p4_16_samples/default-switch.p4 @@ -0,0 +1,16 @@ +control ctrl() { + action a() {} + action b() {} + + table t { + actions = { a; b; } + default_action = a; + } + + apply { + switch (t.apply().action_run) { + b: + default: { return; } + } + } +} diff --git a/testdata/p4_16_samples_outputs/default-switch-first.p4 b/testdata/p4_16_samples_outputs/default-switch-first.p4 new file mode 100644 index 0000000000..cfacfa16e8 --- /dev/null +++ b/testdata/p4_16_samples_outputs/default-switch-first.p4 @@ -0,0 +1,22 @@ +control ctrl() { + action a() { + } + action b() { + } + table t { + actions = { + a(); + b(); + } + default_action = a(); + } + apply { + switch (t.apply().action_run) { + b: + default: { + return; + } + } + } +} + diff --git a/testdata/p4_16_samples_outputs/default-switch-frontend.p4 b/testdata/p4_16_samples_outputs/default-switch-frontend.p4 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testdata/p4_16_samples_outputs/default-switch.p4 b/testdata/p4_16_samples_outputs/default-switch.p4 new file mode 100644 index 0000000000..038d0ca45e --- /dev/null +++ b/testdata/p4_16_samples_outputs/default-switch.p4 @@ -0,0 +1,22 @@ +control ctrl() { + action a() { + } + action b() { + } + table t { + actions = { + a; + b; + } + default_action = a; + } + apply { + switch (t.apply().action_run) { + b: + default: { + return; + } + } + } +} + diff --git a/testdata/p4_16_samples_outputs/default-switch.p4-stderr b/testdata/p4_16_samples_outputs/default-switch.p4-stderr new file mode 100644 index 0000000000..d03fec280c --- /dev/null +++ b/testdata/p4_16_samples_outputs/default-switch.p4-stderr @@ -0,0 +1,4 @@ +default-switch.p4(1): [--Wwarn=unused] warning: Control ctrl is not used; removing +control ctrl() { + ^^^^ +[--Wwarn=missing] warning: Program does not contain a `main' module