1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29/*
30 * ASSERTION:
31 * Test circular declaration of translations
32 *
33 * SECTION: Translators/ Translator Declarations
34 * SECTION: Translators/ Translate Operator
35 */
36
37#pragma D option quiet
38
39struct input_struct {
40	int i;
41	char c;
42};
43
44struct output_struct {
45	int myi;
46	char myc;
47};
48
49translator struct output_struct < struct input_struct ivar >
50{
51	myi = ((struct input_struct ) ivar).i;
52	myc = ((struct input_struct ) ivar).c;
53};
54
55translator struct input_struct < struct output_struct uvar >
56{
57	i = ((struct output_struct ) uvar).myi;
58	c = ((struct output_struct ) uvar).myc;
59};
60
61struct input_struct f1;
62struct output_struct f2;
63
64BEGIN
65{
66	f1.i = 10;
67	f1.c = 'c';
68
69	f2.myi = 100;
70	f2.myc = 'd';
71
72	printf("Testing circular translations\n");
73	forwardi = xlate < struct output_struct > (f1).myi;
74	forwardc = xlate < struct output_struct > (f1).myc;
75	backwardi = xlate < struct input_struct > (f2).i;
76	backwardc = xlate < struct input_struct > (f2).c;
77
78	printf("forwardi: %d\tforwardc: %c\n", forwardi, forwardc);
79	printf("backwardi: %d\tbackwardc: %c", backwardi, backwardc);
80	exit(0);
81}
82
83BEGIN
84/(10 == forwardi) && ('c' == forwardc) && (100 == backwardi) &&
85    ('d' == backwardc)/
86{
87	exit(0);
88}
89
90BEGIN
91/(10 != forwardi) || ('c' != forwardc) || (100 != backwardi) ||
92    ('d' != backwardc)/
93{
94	exit(1);
95}
96
97ERROR
98{
99	exit(1);
100}
101