aboutsummaryrefslogtreecommitdiff
path: root/tests/canonical/le_test_file.pdl
blob: fa87314512683795936be9335a632db439ee797b (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
little_endian_packets

// Preliminary definitions

custom_field SizedCustomField : 8 "SizedCustomField"
custom_field UnsizedCustomField "UnsizedCustomField"
checksum Checksum : 8 "Checksum"

enum Enum7 : 7 {
    A = 1,
    B = 2,
}

enum Enum16 : 16 {
    A = 0xaabb,
    B = 0xccdd,
}

struct SizedStruct {
    a: 8,
}

struct UnsizedStruct {
    _size_(array): 2,
    _reserved_: 6,
    array: 8[],
}

group ScalarGroup {
    a: 16
}

group EnumGroup {
    a: Enum16
}

packet ScalarParent {
    a: 8,
    _size_(_payload_): 8,
    _payload_
}

packet EnumParent {
    a: Enum16,
    _size_(_payload_): 8,
    _payload_
}

packet EmptyParent : ScalarParent {
    _payload_
}

// Start: little_endian_only
packet PartialParent5 {
    a: 5,
    _payload_
}

packet PartialParent12 {
    a: 12,
    _payload_
}
// End: little_endian_only

// Packet bit fields

// The parser must be able to handle bit fields with scalar values
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Scalar_Field {
    a: 7,
    c: 57,
}

// The parser must be able to handle bit fields with enum values
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Enum_Field {
    a: Enum7,
    c: 57,
}

// The parser must be able to handle bit fields with reserved fields
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Reserved_Field {
    a: 7,
    _reserved_: 2,
    c: 55,
}

// The parser must be able to handle bit fields with size fields
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Size_Field {
    _size_(b): 3,
    a: 61,
    b: 8[],
}

// The parser must be able to handle bit fields with count fields
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_Count_Field {
    _count_(b): 3,
    a: 61,
    b: 8[],
}

// The parser must be able to handle bit fields with fixed scalar values
// up to 64 bits wide.  The parser should generate a static size guard.
packet Packet_FixedScalar_Field {
    _fixed_ = 7 : 7,
    b: 57,
}

// The parser must be able to handle bit fields with fixed enum values
// up to 64 bits wide. The parser should generate a static size guard.
packet Packet_FixedEnum_Field {
    _fixed_ = A : Enum7,
    b: 57,
}

// Packet payload fields

// The parser must be able to handle sized payload fields without
// size modifier.
packet Packet_Payload_Field_VariableSize {
    _size_(_payload_): 3,
    _reserved_: 5,
    _payload_
}

// The parser must be able to handle sized payload fields with
// size modifier.
packet Packet_Payload_Field_SizeModifier {
    _size_(_payload_): 3,
    _reserved_: 5,
    _payload_ : [+2],
}

// The parser must be able to handle payload fields of unkonwn size followed
// by fields of statically known size. The remaining span is integrated
// in the packet.
packet Packet_Payload_Field_UnknownSize {
    _payload_,
    a: 16,
}

// The parser must be able to handle payload fields of unkonwn size.
// The remaining span is integrated in the packet.
packet Packet_Payload_Field_UnknownSize_Terminal {
    a: 16,
    _payload_,
}

// Packet body fields

// The parser must be able to handle sized body fields without
// size modifier when the packet has no children.
packet Packet_Body_Field_VariableSize {
    _size_(_body_): 3,
    _reserved_: 5,
    _body_
}

// The parser must be able to handle body fields of unkonwn size followed
// by fields of statically known size. The remaining span is integrated
// in the packet.
packet Packet_Body_Field_UnknownSize {
    _body_,
    a: 16,
}

// The parser must be able to handle body fields of unkonwn size.
// The remaining span is integrated in the packet.
packet Packet_Body_Field_UnknownSize_Terminal {
    a: 16,
    _body_,
}

// Packet group fields

packet Packet_ScalarGroup_Field {
    ScalarGroup { a = 42 },
}

packet Packet_EnumGroup_Field {
    EnumGroup { a = A },
}

// Packet checksum fields

// The parser must be able to handle checksum fields if the checksum value
// field is positioned at constant offset from the checksum start.
// The parser should generate a checksum guard for the buffer covered by the
// checksum.
packet Packet_Checksum_Field_FromStart {
    _checksum_start_(crc),
    a: 16,
    b: 16,
    crc: Checksum,
}

// The parser must be able to handle checksum fields if the checksum value
// field is positioned at constant offset from the end of the packet.
// The parser should generate a checksum guard for the buffer covered by the
// checksum.
packet Packet_Checksum_Field_FromEnd {
    _checksum_start_(crc),
    _payload_,
    crc: Checksum,
    a: 16,
    b: 16,
}

// Packet typedef fields

// The parser must be able to handle struct fields.
// The size guard is generated by the Struct parser.
packet Packet_Struct_Field {
    a: SizedStruct,
    b: UnsizedStruct,
}

// The parser must be able to handle custom fields of constant size.
// The parser should generate a static size guard.
packet Packet_Custom_Field_ConstantSize {
    a: SizedCustomField,
}

// The parser must be able to handle custom fields of undefined size.
// No size guard possible.
packet Packet_Custom_Field_VariableSize {
    a: UnsizedCustomField,
}

// Array field configurations.
// Add constructs for all configurations of type, size, and padding:
//
// - type: u8, u16, enum, struct with static size, struct with dynamic size
// - size: constant, with size field, with count field, unspecified
//
// The type u8 is tested separately since it is likely to be handled
// idiomatically by the specific language generators.

packet Packet_Array_Field_ByteElement_ConstantSize {
    array: 8[4],
}

packet Packet_Array_Field_ByteElement_VariableSize {
    _size_(array) : 4,
    _reserved_: 4,
    array: 8[],
}

packet Packet_Array_Field_ByteElement_VariableCount {
    _count_(array) : 4,
    _reserved_: 4,
    array: 8[],
}

packet Packet_Array_Field_ByteElement_UnknownSize {
    array: 8[],
}

packet Packet_Array_Field_ScalarElement_ConstantSize {
    array: 16[4],
}

packet Packet_Array_Field_ScalarElement_VariableSize {
    _size_(array) : 4,
    _reserved_: 4,
    array: 16[],
}

packet Packet_Array_Field_ScalarElement_VariableCount {
    _count_(array) : 4,
    _reserved_: 4,
    array: 16[],
}

packet Packet_Array_Field_ScalarElement_UnknownSize {
    array: 16[],
}

packet Packet_Array_Field_EnumElement_ConstantSize {
    array: Enum16[4],
}

packet Packet_Array_Field_EnumElement_VariableSize {
    _size_(array) : 4,
    _reserved_: 4,
    array: Enum16[],
}

packet Packet_Array_Field_EnumElement_VariableCount {
    _count_(array) : 4,
    _reserved_: 4,
    array: Enum16[],
}

packet Packet_Array_Field_EnumElement_UnknownSize {
    array: Enum16[],
}

packet Packet_Array_Field_SizedElement_ConstantSize {
    array: SizedStruct[4],
}

packet Packet_Array_Field_SizedElement_VariableSize {
    _size_(array) : 4,
    _reserved_: 4,
    array: SizedStruct[],
}

packet Packet_Array_Field_SizedElement_VariableCount {
    _count_(array) : 4,
    _reserved_: 4,
    array: SizedStruct[],
}

packet Packet_Array_Field_SizedElement_UnknownSize {
    array: SizedStruct[],
}

packet Packet_Array_Field_UnsizedElement_ConstantSize {
    array: UnsizedStruct[4],
}

packet Packet_Array_Field_UnsizedElement_VariableSize {
    _size_(array) : 4,
    _reserved_: 4,
    array: UnsizedStruct[],
}

packet Packet_Array_Field_UnsizedElement_VariableCount {
    _count_(array) : 4,
    _reserved_: 4,
    array: UnsizedStruct[],
}

packet Packet_Array_Field_UnsizedElement_UnknownSize {
    array: UnsizedStruct[],
}

// The parser must support complex size modifiers on arrays whose size is
// specified by a size field.
packet Packet_Array_Field_UnsizedElement_SizeModifier {
    _size_(array) : 4,
    _reserved_: 4,
    array: UnsizedStruct[+2],
}

// The parser must be able to handle arrays with padded size.
packet Packet_Array_Field_SizedElement_VariableSize_Padded {
    _size_(array) : 4,
    _reserved_: 4,
    array: 16[],
    _padding_ [16],
}

// The parser must be able to handle arrays with padded size.
packet Packet_Array_Field_UnsizedElement_VariableCount_Padded {
    _count_(array) : 8,
    array: UnsizedStruct[],
    _padding_ [16],
}

packet Packet_Optional_Scalar_Field {
    c0: 1,
    c1: 1,
    _reserved_: 6,
    a: 24 if c0 = 0,
    b: 32 if c1 = 1,
}

packet Packet_Optional_Enum_Field {
    c0: 1,
    c1: 1,
    _reserved_: 6,
    a: Enum16 if c0 = 0,
    b: Enum16 if c1 = 1,
}

packet Packet_Optional_Struct_Field {
    c0: 1,
    c1: 1,
    _reserved_: 6,
    a: SizedStruct if c0 = 0,
    b: UnsizedStruct if c1 = 1,
}

// Packet inheritance

// The parser must handle specialization into
// any child packet of a parent packet with scalar constraints.
packet ScalarChild_A : ScalarParent (a = 0) {
    b: 8,
}

// The parser must handle specialization into
// any child packet of a parent packet with scalar constraints.
packet ScalarChild_B : ScalarParent (a = 1) {
    c: 16,
}

// The parser must handle specialization into
// any child packet of a parent packet with enum constraints.
packet EnumChild_A : EnumParent (a = A) {
    b: 8,
}

// The parser must handle specialization into
// any child packet of a parent packet with enum constraints.
packet EnumChild_B : EnumParent (a = B) {
    c: 16,
}

// The parser must handle aliasing of packets
// through inheritance with no constraints
packet AliasedChild_A : EmptyParent (a = 2) {
    b: 8,
}

// The parser must handle aliasing of packets
// through inheritance with no constraints
packet AliasedChild_B : EmptyParent (a = 3) {
    c: 16,
}

// Start: little_endian_only

// The parser must handle inheritance of packets with payloads starting
// on a shifted byte boundary, as long as the first fields of the child
// complete the bit fields.
packet PartialChild5_A : PartialParent5 (a = 0) {
    b: 11,
}

// The parser must handle inheritance of packets with payloads starting
// on a shifted byte boundary, as long as the first fields of the child
// complete the bit fields.
packet PartialChild5_B : PartialParent5 (a = 1) {
    c: 27,
}

// The parser must handle inheritance of packets with payloads starting
// on a shifted byte boundary, as long as the first fields of the child
// complete the bit fields.
packet PartialChild12_A : PartialParent12 (a = 2) {
    d: 4,
}

// The parser must handle inheritance of packets with payloads starting
// on a shifted byte boundary, as long as the first fields of the child
// complete the bit fields.
packet PartialChild12_B : PartialParent12 (a = 3) {
    e: 20,
}

// End: little_endian_only

// Struct bit fields

// The parser must be able to handle bit fields with scalar values
// up to 64 bits wide.  The parser should generate a static size guard.
struct Struct_Scalar_Field {
    a: 7,
    c: 57,
}

// The parser must be able to handle bit fields with enum values
// up to 64 bits wide.  The parser should generate a static size guard.
struct Struct_Enum_Field_ {
    a: Enum7,
    c: 57,
}
packet Struct_Enum_Field {
    s: Struct_Enum_Field_,
}

// The parser must be able to handle bit fields with reserved fields
// up to 64 bits wide.  The parser should generate a static size guard.
struct Struct_Reserved_Field_ {
    a: 7,
    _reserved_: 2,
    c: 55,
}
packet Struct_Reserved_Field {
    s: Struct_Reserved_Field_,
}

// The parser must be able to handle bit fields with size fields
// up to 64 bits wide.  The parser should generate a static size guard.
struct Struct_Size_Field_ {
    _size_(b): 3,
    a: 61,
    b: 8[],
}
packet Struct_Size_Field {
    s: Struct_Size_Field_,
}

// The parser must be able to handle bit fields with count fields
// up to 64 bits wide.  The parser should generate a static size guard.
struct Struct_Count_Field_ {
    _count_(b): 3,
    a: 61,
    b: 8[],
}
packet Struct_Count_Field {
    s: Struct_Count_Field_,
}

// The parser must be able to handle bit fields with fixed scalar values
// up to 64 bits wide.  The parser should generate a static size guard.
struct Struct_FixedScalar_Field_ {
    _fixed_ = 7 : 7,
    b: 57,
}
packet Struct_FixedScalar_Field {
    s: Struct_FixedScalar_Field_,
}

// The parser must be able to handle bit fields with fixed enum values
// up to 64 bits wide. The parser should generate a static size guard.
struct Struct_FixedEnum_Field_ {
    _fixed_ = A : Enum7,
    b: 57,
}
packet Struct_FixedEnum_Field {
    s: Struct_FixedEnum_Field_,
}

// Struct group fields

struct Struct_ScalarGroup_Field_ {
    ScalarGroup { a = 42 },
}
packet Struct_ScalarGroup_Field {
    s: Struct_ScalarGroup_Field_,
}

struct Struct_EnumGroup_Field_ {
    EnumGroup { a = A },
}
packet Struct_EnumGroup_Field {
    s: Struct_EnumGroup_Field_,
}

// Struct checksum fields

// The parser must be able to handle checksum fields if the checksum value
// field is positioned at constant offset from the checksum start.
// The parser should generate a checksum guard for the buffer covered by the
// checksum.
struct Struct_Checksum_Field_FromStart_ {
    _checksum_start_(crc),
    a: 16,
    b: 16,
    crc: Checksum,
}
packet Struct_Checksum_Field_FromStart {
    s: Struct_Checksum_Field_FromStart_,
}

// The parser must be able to handle checksum fields if the checksum value
// field is positioned at constant offset from the end of the packet.
// The parser should generate a checksum guard for the buffer covered by the
// checksum.
struct Struct_Checksum_Field_FromEnd_ {
    _checksum_start_(crc),
    _payload_,
    crc: Checksum,
    a: 16,
    b: 16,
}
packet Struct_Checksum_Field_FromEnd {
    s: Struct_Checksum_Field_FromEnd_,
}

// Struct typedef fields

// The parser must be able to handle struct fields.
// The size guard is generated by the Struct parser.
packet Struct_Struct_Field {
    a: SizedStruct,
    b: UnsizedStruct,
}

// The parser must be able to handle custom fields of constant size.
// The parser should generate a static size guard.
struct Struct_Custom_Field_ConstantSize_ {
    a: SizedCustomField,
}
packet Struct_Custom_Field_ConstantSize {
    s: Struct_Custom_Field_ConstantSize_,
}

// The parser must be able to handle custom fields of undefined size.
// No size guard possible.
struct Struct_Custom_Field_VariableSize_ {
    a: UnsizedCustomField,
}
packet Struct_Custom_Field_VariableSize {
    s: Struct_Custom_Field_VariableSize_,
}

// Array field configurations.
// Add constructs for all configurations of type, size, and padding:
//
// - type: u8, u16, enum, struct with static size, struct with dynamic size
// - size: constant, with size field, with count field, unspecified
//
// The type u8 is tested separately since it is likely to be handled
// idiomatically by the specific language generators.

struct Struct_Array_Field_ByteElement_ConstantSize_ {
    array: 8[4],
}
packet Struct_Array_Field_ByteElement_ConstantSize {
    s: Struct_Array_Field_ByteElement_ConstantSize_,
}

struct Struct_Array_Field_ByteElement_VariableSize_ {
    _size_(array) : 4,
    _reserved_: 4,
    array: 8[],
}
packet Struct_Array_Field_ByteElement_VariableSize {
    s: Struct_Array_Field_ByteElement_VariableSize_,
}

struct Struct_Array_Field_ByteElement_VariableCount_ {
    _count_(array) : 4,
    _reserved_: 4,
    array: 8[],
}
packet Struct_Array_Field_ByteElement_VariableCount {
    s: Struct_Array_Field_ByteElement_VariableCount_,
}

struct Struct_Array_Field_ByteElement_UnknownSize_ {
    array: 8[],
}
packet Struct_Array_Field_ByteElement_UnknownSize {
    s: Struct_Array_Field_ByteElement_UnknownSize_,
}

struct Struct_Array_Field_ScalarElement_ConstantSize_ {
    array: 16[4],
}
packet Struct_Array_Field_ScalarElement_ConstantSize {
    s: Struct_Array_Field_ScalarElement_ConstantSize_,
}

struct Struct_Array_Field_ScalarElement_VariableSize_ {
    _size_(array) : 4,
    _reserved_: 4,
    array: 16[],
}
packet Struct_Array_Field_ScalarElement_VariableSize {
    s: Struct_Array_Field_ScalarElement_VariableSize_,
}

struct Struct_Array_Field_ScalarElement_VariableCount_ {
    _count_(array) : 4,
    _reserved_: 4,
    array: 16[],
}
packet Struct_Array_Field_ScalarElement_VariableCount {
    s: Struct_Array_Field_ScalarElement_VariableCount_,
}

struct Struct_Array_Field_ScalarElement_UnknownSize_ {
    array: 16[],
}
packet Struct_Array_Field_ScalarElement_UnknownSize {
    s: Struct_Array_Field_ScalarElement_UnknownSize_,
}

struct Struct_Array_Field_EnumElement_ConstantSize_ {
    array: Enum16[4],
}
packet Struct_Array_Field_EnumElement_ConstantSize {
    s: Struct_Array_Field_EnumElement_ConstantSize_,
}

struct Struct_Array_Field_EnumElement_VariableSize_ {
    _size_(array) : 4,
    _reserved_: 4,
    array: Enum16[],
}
packet Struct_Array_Field_EnumElement_VariableSize {
    s: Struct_Array_Field_EnumElement_VariableSize_,
}

struct Struct_Array_Field_EnumElement_VariableCount_ {
    _count_(array) : 4,
    _reserved_: 4,
    array: Enum16[],
}
packet Struct_Array_Field_EnumElement_VariableCount {
    s: Struct_Array_Field_EnumElement_VariableCount_,
}

struct Struct_Array_Field_EnumElement_UnknownSize_ {
    array: Enum16[],
}
packet Struct_Array_Field_EnumElement_UnknownSize {
    s: Struct_Array_Field_EnumElement_UnknownSize_,
}

struct Struct_Array_Field_SizedElement_ConstantSize_ {
    array: SizedStruct[4],
}
packet Struct_Array_Field_SizedElement_ConstantSize {
    s: Struct_Array_Field_SizedElement_ConstantSize_,
}

struct Struct_Array_Field_SizedElement_VariableSize_ {
    _size_(array) : 4,
    _reserved_: 4,
    array: SizedStruct[],
}
packet Struct_Array_Field_SizedElement_VariableSize {
    s: Struct_Array_Field_SizedElement_VariableSize_,
}

struct Struct_Array_Field_SizedElement_VariableCount_ {
    _count_(array) : 4,
    _reserved_: 4,
    array: SizedStruct[],
}
packet Struct_Array_Field_SizedElement_VariableCount {
    s: Struct_Array_Field_SizedElement_VariableCount_,
}

struct Struct_Array_Field_SizedElement_UnknownSize_ {
    array: SizedStruct[],
}
packet Struct_Array_Field_SizedElement_UnknownSize {
    s: Struct_Array_Field_SizedElement_UnknownSize_,
}

struct Struct_Array_Field_UnsizedElement_ConstantSize_ {
    array: UnsizedStruct[4],
}
packet Struct_Array_Field_UnsizedElement_ConstantSize {
    s: Struct_Array_Field_UnsizedElement_ConstantSize_,
}

struct Struct_Array_Field_UnsizedElement_VariableSize_ {
    _size_(array) : 4,
    _reserved_: 4,
    array: UnsizedStruct[],
}
packet Struct_Array_Field_UnsizedElement_VariableSize {
    s: Struct_Array_Field_UnsizedElement_VariableSize_,
}

struct Struct_Array_Field_UnsizedElement_VariableCount_ {
    _count_(array) : 4,
    _reserved_: 4,
    array: UnsizedStruct[],
}
packet Struct_Array_Field_UnsizedElement_VariableCount {
    s: Struct_Array_Field_UnsizedElement_VariableCount_,
}

struct Struct_Array_Field_UnsizedElement_UnknownSize_ {
    array: UnsizedStruct[],
}
packet Struct_Array_Field_UnsizedElement_UnknownSize {
    s: Struct_Array_Field_UnsizedElement_UnknownSize_,
}

// The parser must support complex size modifiers on arrays whose size is
// specified by a size field.
struct Struct_Array_Field_UnsizedElement_SizeModifier_ {
    _size_(array) : 4,
    _reserved_: 4,
    array: UnsizedStruct[+2],
}
packet Struct_Array_Field_UnsizedElement_SizeModifier {
    s: Struct_Array_Field_UnsizedElement_SizeModifier_,
}

// The parser must be able to handle arrays with padded size.
struct Struct_Array_Field_SizedElement_VariableSize_Padded_ {
    _size_(array) : 4,
    _reserved_: 4,
    array: 16[],
    _padding_ [16],
}
packet Struct_Array_Field_SizedElement_VariableSize_Padded {
    s: Struct_Array_Field_SizedElement_VariableSize_Padded_,
}

// The parser must be able to handle arrays with padded size.
struct Struct_Array_Field_UnsizedElement_VariableCount_Padded_ {
    _count_(array) : 8,
    array: UnsizedStruct[],
    _padding_ [16],
}
packet Struct_Array_Field_UnsizedElement_VariableCount_Padded {
    s: Struct_Array_Field_UnsizedElement_VariableCount_Padded_,
}

struct Struct_Optional_Scalar_Field_ {
    c0: 1,
    c1: 1,
    _reserved_: 6,
    a: 24 if c0 = 0,
    b: 32 if c1 = 1,
}

packet Struct_Optional_Scalar_Field {
    s: Struct_Optional_Scalar_Field_,
}

struct Struct_Optional_Enum_Field_ {
    c0: 1,
    c1: 1,
    _reserved_: 6,
    a: Enum16 if c0 = 0,
    b: Enum16 if c1 = 1,
}

packet Struct_Optional_Enum_Field {
    s: Struct_Optional_Enum_Field_,
}

struct Struct_Optional_Struct_Field_ {
    c0: 1,
    c1: 1,
    _reserved_: 6,
    a: SizedStruct if c0 = 0,
    b: UnsizedStruct if c1 = 1,
}

packet Struct_Optional_Struct_Field {
    s: Struct_Optional_Struct_Field_,
}