From 57657912d21e544ed36bb1a97b91e7de44e28695 Mon Sep 17 00:00:00 2001 From: Kyle Cripps <60898032+kfcripps@users.noreply.github.com> Date: Thu, 18 Jul 2024 08:06:09 -0700 Subject: [PATCH] Add tests from issue 4507 (#4816) Signed-off-by: Kyle Cripps --- testdata/p4_16_samples/issue4507_1.p4 | 35 ++++++++++++++++ testdata/p4_16_samples/issue4507_2.p4 | 40 +++++++++++++++++++ .../issue4507_1-first.p4 | 31 ++++++++++++++ .../issue4507_1-frontend.p4 | 19 +++++++++ .../issue4507_1-midend.p4 | 19 +++++++++ testdata/p4_16_samples_outputs/issue4507_1.p4 | 33 +++++++++++++++ .../issue4507_1.p4-stderr | 6 +++ .../issue4507_2-first.p4 | 35 ++++++++++++++++ .../issue4507_2-frontend.p4 | 19 +++++++++ .../issue4507_2-midend.p4 | 19 +++++++++ testdata/p4_16_samples_outputs/issue4507_2.p4 | 37 +++++++++++++++++ .../issue4507_2.p4-stderr | 6 +++ 12 files changed, 299 insertions(+) create mode 100644 testdata/p4_16_samples/issue4507_1.p4 create mode 100644 testdata/p4_16_samples/issue4507_2.p4 create mode 100644 testdata/p4_16_samples_outputs/issue4507_1-first.p4 create mode 100644 testdata/p4_16_samples_outputs/issue4507_1-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/issue4507_1-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/issue4507_1.p4 create mode 100644 testdata/p4_16_samples_outputs/issue4507_1.p4-stderr create mode 100644 testdata/p4_16_samples_outputs/issue4507_2-first.p4 create mode 100644 testdata/p4_16_samples_outputs/issue4507_2-frontend.p4 create mode 100644 testdata/p4_16_samples_outputs/issue4507_2-midend.p4 create mode 100644 testdata/p4_16_samples_outputs/issue4507_2.p4 create mode 100644 testdata/p4_16_samples_outputs/issue4507_2.p4-stderr diff --git a/testdata/p4_16_samples/issue4507_1.p4 b/testdata/p4_16_samples/issue4507_1.p4 new file mode 100644 index 0000000000..5dc1d7c863 --- /dev/null +++ b/testdata/p4_16_samples/issue4507_1.p4 @@ -0,0 +1,35 @@ +extern void __e(in bit<28> arg); +extern void __e2(in bit<28> arg); + +control C() { + action bar(bool a, bool b) { + bit<28> x; bit<28> y; + if (a) { + if (b) { + __e(x); + } + } else { + if (b) { + __e2(y); + } + } + } + + action foo() { + bar(true, false); + } + + table t { + actions = { foo; } + default_action = foo; + } + + apply { + t.apply(); + } +} + +control proto(); +package top(proto p); + +top(C()) main; diff --git a/testdata/p4_16_samples/issue4507_2.p4 b/testdata/p4_16_samples/issue4507_2.p4 new file mode 100644 index 0000000000..b71ca9380e --- /dev/null +++ b/testdata/p4_16_samples/issue4507_2.p4 @@ -0,0 +1,40 @@ +extern void __e(in bit<28> arg); +extern void __e2(in bit<28> arg); + +control C() { + action bar(bool a, bool b) { + bit<28> x; bit<28> y; + if (a) { + if (b) { + __e(x); + } + } else { + if (b) { + __e2(y); + } + } + } + + action baz() { + bar(true, false); + } + + action foo() { + baz(); + baz(); + } + + table t { + actions = { foo; } + default_action = foo; + } + + apply { + t.apply(); + } +} + +control proto(); +package top(proto p); + +top(C()) main; diff --git a/testdata/p4_16_samples_outputs/issue4507_1-first.p4 b/testdata/p4_16_samples_outputs/issue4507_1-first.p4 new file mode 100644 index 0000000000..3f434f6f9d --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue4507_1-first.p4 @@ -0,0 +1,31 @@ +extern void __e(in bit<28> arg); +extern void __e2(in bit<28> arg); +control C() { + action bar(bool a, bool b) { + bit<28> x; + bit<28> y; + if (a) { + if (b) { + __e(x); + } + } else if (b) { + __e2(y); + } + } + action foo() { + bar(true, false); + } + table t { + actions = { + foo(); + } + default_action = foo(); + } + apply { + t.apply(); + } +} + +control proto(); +package top(proto p); +top(C()) main; diff --git a/testdata/p4_16_samples_outputs/issue4507_1-frontend.p4 b/testdata/p4_16_samples_outputs/issue4507_1-frontend.p4 new file mode 100644 index 0000000000..709770057c --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue4507_1-frontend.p4 @@ -0,0 +1,19 @@ +extern void __e(in bit<28> arg); +extern void __e2(in bit<28> arg); +control C() { + @name("C.foo") action foo() { + } + @name("C.t") table t_0 { + actions = { + foo(); + } + default_action = foo(); + } + apply { + t_0.apply(); + } +} + +control proto(); +package top(proto p); +top(C()) main; diff --git a/testdata/p4_16_samples_outputs/issue4507_1-midend.p4 b/testdata/p4_16_samples_outputs/issue4507_1-midend.p4 new file mode 100644 index 0000000000..709770057c --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue4507_1-midend.p4 @@ -0,0 +1,19 @@ +extern void __e(in bit<28> arg); +extern void __e2(in bit<28> arg); +control C() { + @name("C.foo") action foo() { + } + @name("C.t") table t_0 { + actions = { + foo(); + } + default_action = foo(); + } + apply { + t_0.apply(); + } +} + +control proto(); +package top(proto p); +top(C()) main; diff --git a/testdata/p4_16_samples_outputs/issue4507_1.p4 b/testdata/p4_16_samples_outputs/issue4507_1.p4 new file mode 100644 index 0000000000..d87f8c69be --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue4507_1.p4 @@ -0,0 +1,33 @@ +extern void __e(in bit<28> arg); +extern void __e2(in bit<28> arg); +control C() { + action bar(bool a, bool b) { + bit<28> x; + bit<28> y; + if (a) { + if (b) { + __e(x); + } + } else { + if (b) { + __e2(y); + } + } + } + action foo() { + bar(true, false); + } + table t { + actions = { + foo; + } + default_action = foo; + } + apply { + t.apply(); + } +} + +control proto(); +package top(proto p); +top(C()) main; diff --git a/testdata/p4_16_samples_outputs/issue4507_1.p4-stderr b/testdata/p4_16_samples_outputs/issue4507_1.p4-stderr new file mode 100644 index 0000000000..0887a1433b --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue4507_1.p4-stderr @@ -0,0 +1,6 @@ +issue4507_1.p4(9): [--Wwarn=uninitialized_use] warning: x may be uninitialized + __e(x); + ^ +issue4507_1.p4(13): [--Wwarn=uninitialized_use] warning: y may be uninitialized + __e2(y); + ^ diff --git a/testdata/p4_16_samples_outputs/issue4507_2-first.p4 b/testdata/p4_16_samples_outputs/issue4507_2-first.p4 new file mode 100644 index 0000000000..3ab4f9752f --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue4507_2-first.p4 @@ -0,0 +1,35 @@ +extern void __e(in bit<28> arg); +extern void __e2(in bit<28> arg); +control C() { + action bar(bool a, bool b) { + bit<28> x; + bit<28> y; + if (a) { + if (b) { + __e(x); + } + } else if (b) { + __e2(y); + } + } + action baz() { + bar(true, false); + } + action foo() { + baz(); + baz(); + } + table t { + actions = { + foo(); + } + default_action = foo(); + } + apply { + t.apply(); + } +} + +control proto(); +package top(proto p); +top(C()) main; diff --git a/testdata/p4_16_samples_outputs/issue4507_2-frontend.p4 b/testdata/p4_16_samples_outputs/issue4507_2-frontend.p4 new file mode 100644 index 0000000000..709770057c --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue4507_2-frontend.p4 @@ -0,0 +1,19 @@ +extern void __e(in bit<28> arg); +extern void __e2(in bit<28> arg); +control C() { + @name("C.foo") action foo() { + } + @name("C.t") table t_0 { + actions = { + foo(); + } + default_action = foo(); + } + apply { + t_0.apply(); + } +} + +control proto(); +package top(proto p); +top(C()) main; diff --git a/testdata/p4_16_samples_outputs/issue4507_2-midend.p4 b/testdata/p4_16_samples_outputs/issue4507_2-midend.p4 new file mode 100644 index 0000000000..709770057c --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue4507_2-midend.p4 @@ -0,0 +1,19 @@ +extern void __e(in bit<28> arg); +extern void __e2(in bit<28> arg); +control C() { + @name("C.foo") action foo() { + } + @name("C.t") table t_0 { + actions = { + foo(); + } + default_action = foo(); + } + apply { + t_0.apply(); + } +} + +control proto(); +package top(proto p); +top(C()) main; diff --git a/testdata/p4_16_samples_outputs/issue4507_2.p4 b/testdata/p4_16_samples_outputs/issue4507_2.p4 new file mode 100644 index 0000000000..18113b1f60 --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue4507_2.p4 @@ -0,0 +1,37 @@ +extern void __e(in bit<28> arg); +extern void __e2(in bit<28> arg); +control C() { + action bar(bool a, bool b) { + bit<28> x; + bit<28> y; + if (a) { + if (b) { + __e(x); + } + } else { + if (b) { + __e2(y); + } + } + } + action baz() { + bar(true, false); + } + action foo() { + baz(); + baz(); + } + table t { + actions = { + foo; + } + default_action = foo; + } + apply { + t.apply(); + } +} + +control proto(); +package top(proto p); +top(C()) main; diff --git a/testdata/p4_16_samples_outputs/issue4507_2.p4-stderr b/testdata/p4_16_samples_outputs/issue4507_2.p4-stderr new file mode 100644 index 0000000000..e1c35c2e0a --- /dev/null +++ b/testdata/p4_16_samples_outputs/issue4507_2.p4-stderr @@ -0,0 +1,6 @@ +issue4507_2.p4(9): [--Wwarn=uninitialized_use] warning: x may be uninitialized + __e(x); + ^ +issue4507_2.p4(13): [--Wwarn=uninitialized_use] warning: y may be uninitialized + __e2(y); + ^