forked from p4lang/p4c
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathissue5653.p4
More file actions
66 lines (56 loc) · 1.38 KB
/
Copy pathissue5653.p4
File metadata and controls
66 lines (56 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* SPDX-FileCopyrightText: 2026
*
* SPDX-License-Identifier: Apache-2.0
*
* Regression test for issue #5653: comparison with {#} literal fails to compile.
*/
#include <core.p4>
header h_t { bit<8> f; }
header h2_t { bit<16> g; }
header_union hu_t { h_t a; h2_t b; }
struct meta_t {
h_t h;
bit<8> f;
}
struct nested_t {
meta_t m;
}
control C(inout meta_t meta, inout nested_t nested, inout hu_t hu) {
action a() {
if (meta.h == {#})
meta.f = 1;
if (meta.h != {#})
meta.f = 2;
meta.h = {#};
if (!meta.h.isValid())
meta.f = 3;
h_t hcast = (h_t){#};
if (hcast == (h_t){#}) {}
if (hu == {#}) {}
if (hu != {#}) {}
hu = {#};
if (nested.m.h == {#})
nested.m.f = 4;
}
table t {
actions = { a; }
default_action = a;
}
apply {
t.apply();
}
}
parser P(inout meta_t meta, inout nested_t nested, inout hu_t hu) {
state start {
meta.h = {#};
if (meta.h == {#}) {
meta.h.setInvalid();
}
transition accept;
}
}
control proto(inout meta_t meta, inout nested_t nested, inout hu_t hu);
parser par(inout meta_t meta, inout nested_t nested, inout hu_t hu);
package top(par p, proto c);
top(P(), C()) main;