1 /* 2 * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 struct Foo { 25 struct Bar { 26 int x, y; 27 } bar; 28 29 enum Color { 30 red, green, blue 31 } color; 32 }; 33 34 union U { 35 struct Point { 36 short x, y; 37 } point; 38 39 enum RGB { 40 r, g, b 41 } rgb; 42 43 int i; 44 }; 45 46 struct MyStruct { 47 char a; 48 struct { 49 int b; 50 union { 51 int c; 52 }; 53 char d; 54 struct MyStruct_Z { 55 char e; 56 } f; 57 }; 58 union { 59 int g; 60 long long h; 61 }; 62 enum { 63 X, Y, Z 64 }; 65 struct { 66 int i; 67 int j; 68 } k; 69 }; 70 71 union MyUnion { 72 char a; 73 struct { 74 int b; 75 union { 76 int c; 77 }; 78 char d; 79 struct MyUnion_Z { 80 char e; 81 } f; 82 }; 83 struct { 84 int g; 85 int h; 86 }; 87 enum { 88 A, B, C 89 }; 90 union { 91 int i; 92 long long j; 93 } k; 94 }; 95 96 struct X { 97 struct { 98 union { 99 int y; 100 } Z; 101 }; 102 }; 103 104 struct X2 { 105 struct { 106 union { 107 int y; 108 }; // no name this time 109 }; 110 }; 111 112 struct NestedUnion { 113 int x; 114 union { 115 int y; 116 int z; 117 }; 118 };