• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15-- Test cases for types containing types.
16
17[$default byte_order: "LittleEndian"]
18[(cpp) namespace: "emboss::test"]
19
20
21struct Out:
22  struct In:
23    struct InIn:
24      enum InInIn:
25        NO           = 0
26        YES          = 1
27
28      let outer_offset = 24
29
30      0 [+1]  InInIn  field_enum
31      # In2 should be Out.In2, despite In2 appearing in an enclosing scope and
32      # later in the source file.
33
34      1 [+1]  In2     in_2
35
36    0              [+2]  InIn         in_in_1
37
38    2              [+2]  InIn         in_in_2
39
40    4              [+1]  InIn.InInIn  in_in_in_1
41
42    5              [+1]  In2          in_2
43
44    6              [+1]  UInt         name_collision
45    # name_collision should resolve to Out.In.name_collision, not
46    # Out.name_collision, and there should be no error about ambiguous
47    # resolution.  (Note that since field references are actually used at
48    # runtime, and there isn't necessarily any enclosing Out object for an
49    # Out.In at runtime, it does not make sense for a field name to resolve to
50    # a field in an outer struct.)
51    # TODO(bolms): Add a warning for this case, since it is somewhat subtle.
52
53    name_collision [+1]  UInt         name_collision_check
54
55  struct In2:
56    0 [+1]  UInt  field_byte
57
58  0                    [+8]  In              in_1
59  8                    [+8]  In              in_2
60  16                   [+2]  In.InIn         in_in_1
61  18                   [+2]  In.InIn         in_in_2
62  20                   [+1]  In.InIn.InInIn  in_in_in_1
63  21                   [+1]  In.InIn.InInIn  in_in_in_2
64  22                   [+2]  UInt            name_collision
65  In.InIn.outer_offset [+1]  UInt            nested_constant_check
66