diff options
Diffstat (limited to 'src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union')
12 files changed, 816 insertions, 0 deletions
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/Makefile.kup new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/Makefile.kup diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_ADDROF_VAR.UnionPointer.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_ADDROF_VAR.UnionPointer.d new file mode 100644 index 00000000..0a292cde --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_ADDROF_VAR.UnionPointer.d @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Trying to access the members of a user defined union by means of + * a pointer to it should throw a D_ADDROF_VAR compiler error. + * + * SECTION: Structs and Unions/Pointers to Structs + * + */ + +#pragma D option quiet + +union record { + int position; + int content; + +}; + +union record var; +union record *ptr; + +BEGIN +{ + + var.position = 1; + var.content = 'a'; + + ptr = &var; + + printf("ptr->position: %d\tptr->content: %c\n", + ptr->position, ptr->content); + + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon.d new file mode 100644 index 00000000..4adb36e9 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon.d @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Combining multiple union definitions in a single line should throw a + * compiler error. + * + * SECTION: Structs and Unions/Unions + * + */ + +#pragma D option quiet + +union record { + int position; + char content; +} + + +union pirate { + int position; + char content; +}; + +union superStruct super; +union record rec; +union pirate pir; + +BEGIN +{ + rec.content = 'a'; + rec.position = 1; + + pir.content = 'b'; + pir.position = 2; + + printf( + "rec.content: %c\nrec.position: %d\npir.content: %c\npir.position: %d", + rec.content, rec.position, pir.content, pir.position); + + exit(0); +} + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon1.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon1.d new file mode 100644 index 00000000..5506a976 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_COMBO.UnionWithoutColon1.d @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Combining multiple union definitions in a single line should throw a + * compiler error. + * + * SECTION: Structs and Unions/Unions + * + */ + +#pragma D option quiet + +union record { + int position; + char content; +}; + + +union pirate { + int position; + char content; +} + +union record rec; +union pirate pir; + +BEGIN +{ + rec.content = 'a'; + rec.position = 1; + + pir.content = 'b'; + pir.position = 2; + + printf( + "rec.content: %c\nrec.position: %d\npir.content: %c\npir.position: %d", + rec.content, rec.position, pir.content, pir.position); + + exit(0); +} + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.circular.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.circular.d new file mode 100644 index 00000000..ae6e647f --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.circular.d @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * A circular definition of unions (two unions defining each other as + * members) should throw an error at compile time. + * + * SECTION: Structs and Unions/Unions + * + */ + +#pragma D option quiet + +union record { + union pirate p; + int position; + char content; +}; + + +union pirate { + union record r; + int position; + char content; +}; + +union record rec; +union pirate pir; + +BEGIN +{ + rec.position = 0; + rec.content = 'a'; + printf( + "rec.position: %d\nrec.content: %c\n", rec.position, rec.content); + + exit(0); +} + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.order.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.order.d new file mode 100644 index 00000000..9e2ec69f --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.order.d @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * When two unions are defined such that one of them contains the other, the + * inner union has to be defined first. + * + * SECTION: Structs and Unions/Unions + * + */ + +#pragma D option quiet + + +union record { + union pirate p; + int position; + char content; +}; + +union pirate { + int position; + char content; +}; + +union record rec; +union pirate pir; + +BEGIN +{ + rec.content = 'y'; + rec.position = 2; + + pir.content = 'z'; + pir.position = 26; + + printf( + "rec.content: %c\nrec.position: %d\npir.content: %c\npir.position: %d", + rec.content, rec.position, pir.content, pir.position); + + exit(0); +} + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.recursive.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.recursive.d new file mode 100644 index 00000000..2a86b9cd --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.recursive.d @@ -0,0 +1,59 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Recursive naming of unions should produce compiler error. + * + * SECTION: Structs and Unions/Unions + * + */ + +#pragma D option quiet + +union record { + union record rec; + int position; + char content; +}; + +union record r1; +union record r2; + +BEGIN +{ + r1.position = 1; + r1.content = 'a'; + + r2.position = 2; + r2.content = 'b'; + + printf("r1.position: %d\nr1.content: %c\n", r1.position, r1.content); + printf("r2.position: %d\nr2.content: %c\n", r2.position, r2.content); + + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.simple.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.simple.d new file mode 100644 index 00000000..781d7266 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_DECL_INCOMPLETE.simple.d @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Declaring an inner union without defining it else where should throw + * a compiler error. + * + * SECTION: Structs and Unions/Unions + * + */ +#pragma D option quiet + + +union record { + union pirate p; + int position; + char content; +}; + + +union record rec; + +BEGIN +{ + rec.position = 0; + rec.content = 'a'; + printf("rec.position: %d\nrec.content: %c\n", + rec.position, rec.content); + + exit(0); +} + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_PROTO_ARG.DupUnionAssoc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_PROTO_ARG.DupUnionAssoc.d new file mode 100644 index 00000000..f9187412 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/err.D_PROTO_ARG.DupUnionAssoc.d @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Declaring an associative array with a union to be its key type and trying to + * index with another union having the same composition throws an error. + * + * SECTION: Structs and Unions/Unions + * + */ + +#pragma D option quiet + +union record { + int position; + char content; +}; + +union pirate { + int position; + char content; +}; + +union record r1; +union record r2; +union pirate p1; +union pirate p2; + +BEGIN +{ + r1.position = 1; + r1.content = 'a'; + + r2.position = 2; + r2.content = 'b'; + + p1.position = 1; + p1.content = 'a'; + + p2.position = 2; + p2.content = 'b'; + + assoc_array[r1] = 1000; + assoc_array[r2] = 2000; + assoc_array[p1] = 3333; + assoc_array[p2] = 4444; + + printf("assoc_array[r1]: %d\n", assoc_array[r1]); + printf("assoc_array[r2]: %d\n", assoc_array[r2]); + printf("assoc_array[p1]: %d\n", assoc_array[p1]); + printf("assoc_array[p2]: %d\n", assoc_array[p2]); + + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionAssoc.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionAssoc.d new file mode 100644 index 00000000..882b6ae0 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionAssoc.d @@ -0,0 +1,71 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * When a union is used as a key for an associative array, the key is formed + * by using the values of the members of the union variable and not the + * address of the union variable. + * + * SECTION: Structs and Unions/Unions + * + */ + +#pragma D option quiet + +union record { + int position; + char content; +}; + +union record r1; +union record r2; + +BEGIN +{ + r1.position = 1; + r1.content = 'a'; + + r2.position = 1; + r2.content = 'a'; + + assoc_array[r1] = 1000; + assoc_array[r2] = 2000; + + printf("assoc_array[r1]: %d\n", assoc_array[r1]); + printf("assoc_array[r2]: %d\n", assoc_array[r2]); + + exit(0); +} + +END +/assoc_array[r1] != assoc_array[r2]/ +{ + printf("Error"); + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionDataTypes.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionDataTypes.d new file mode 100644 index 00000000..d5d292d1 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionDataTypes.d @@ -0,0 +1,132 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Declaration of the different data types within a union and + * their definitions in a later clause should work fine. + * + * SECTION: Structs and Unions/Unions + * + * NOTES: The floats, doubles and strings have not been implemented yet. + * When they do, appropriate lines in the code below should be uncommented. + * Similarly, the lines with the kmem_flags pointer assignment should be + * uncommented when the issues pertaining to it are clarified. + * + */ + +#pragma D option quiet + +union record { + char new_char; + short new_short; + int new_int; + long new_long; + long long new_long_long; + int8_t new_int8; + int16_t new_int16; + int32_t new_int32; + int64_t new_int64; + intptr_t new_intptr; + uint8_t new_uint8; + uint16_t new_uint16; + uint32_t new_uint32; + uint64_t new_uint64; + uintptr_t new_uintptr; + + /*float new_float; + double new_double; + long double new_long_double; + + string new_string; + */ + + struct { + char ch; + int in; + long lg; + } new_struct; + + union { + char ch; + int in; + long lg; + } new_union; + +enum { + RED, + GREEN, + BLUE +} new_enum; + + + int *pointer; +} var; + +/* + var.pointer = &`kmem_flags; +*/ +BEGIN +{ + var.new_char = 'c'; + var.new_short = 10; + var.new_int = 100; + var.new_long = 1234567890; + var.new_long_long = 1234512345; + var.new_int8 = 'p'; + var.new_int16 = 20; + var.new_int32 = 200; + var.new_int64 = 2000000; + var.new_intptr = 0x12345; + var.new_uint8 = 'q'; + var.new_uint16 = 30; + var.new_uint32 = 300; + var.new_uint64 = 3000000; + var.new_uintptr = 0x67890; + + /* var.new_float = 1.23456; + var.new_double = 2.34567890; + var.new_long_double = 3.567890123; + + var.new_string = "hello"; + */ + + /* + var.pointer = &`kmem_flags; + */ + + var.new_struct.ch = 'c'; + var.new_struct.in = 4; + var.new_struct.lg = 4; + + var.new_union.ch = 'd'; + var.new_union.in = 5; + var.new_union.lg = 5; + + + exit(0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionInside.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionInside.d new file mode 100644 index 00000000..9569002b --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/union/tst.UnionInside.d @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * Verify the nested behavior of unions. + * + * SECTION: Structs and Unions/Unions + * + */ +#pragma D option quiet + +union InnerMost { + int position; + char content; +}; + +union InnerMore { + union InnerMost IMost; + int dummy_More; +}; + +union Inner { + union InnerMore IMore; + int dummy_More; +}; + +union Outer { + union Inner I; + int dummy_More; +}; + +union OuterMore { + union Outer O; + int dummy_More; +}; + +union OuterMost { + union OuterMore OMore; + int dummy_More; +} OMost; + + +BEGIN +{ + + OMost.OMore.O.I.IMore.IMost.position = 5; + OMost.OMore.O.I.IMore.IMost.content = 'e'; + + printf("OMost.OMore.O.I.IMore.IMost.content: %c\n", + OMost.OMore.O.I.IMore.IMost.content); + + exit(0); +} + +END +/'e' != OMost.OMore.O.I.IMore.IMost.content/ +{ + exit(1); +} |