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 /*
28  * ASSERTION:
29  * 	positive type conversion checks
30  *
31  * SECTION: Types, Operators, and Expressions/Type Conversions
32  *
33  * NOTES: not all type conversions are checked.  A lot of this section
34  * 	is tested within other tests.
35  */
36 
37 #pragma D option quiet
38 
39 unsigned int i;
40 char c;
41 short s;
42 long l;
43 long long ll;
44 
45 BEGIN
46 {
47 /* char -> int */
48 	c = 'A';
49 	i = c;
50 	printf("c is %c i is %d\n", c, i);
51 
52 /* int -> char */
53 
54 	i = 1601;
55 	c = i;
56 	printf("i is %d c is %c\n", i, c);
57 
58 /* char -> short */
59 	c = 'A';
60 	s = c;
61 	printf("c is %c s is %d\n", c, s);
62 
63 /* short -> char */
64 
65 	s = 1601;
66 	c = s;
67 	printf("s is %d c is %c\n", s, c);
68 
69 /* int -> short */
70 
71 	i = 1601;
72 	s = i;
73 	printf("i is %d s is %d\n", i, s);
74 
75 /* short -> int */
76 
77 	s = 1601;
78 	i = s;
79 	printf("s is %d i is %d\n", s, i);
80 
81 /* int -> long long */
82 
83 	i = 4294967295;
84 	ll = i;
85 	printf("i is %d ll is %x\n", i, ll);
86 
87 /* long long -> int */
88 
89 	ll = 8589934591;
90 	i = ll;
91 	printf("ll is %d i is %x\n", ll, i);
92 
93 /* char -> long long */
94 
95 	c = 'A';
96 	ll = c;
97 	printf("c is %c ll is %x\n", c, ll);
98 
99 /* long long -> char */
100 
101 	ll = 8589934401;
102 	c = ll;
103 	printf("ll is %x c is %c\n", ll, c);
104 
105 	exit(0);
106 }
107 
108