Fix PR4948 (and a leak): by not destroying the DwarfException
[llvm/avr.git] / test / FrontendC / 2002-07-29-Casts.c
blob44bb6101955486e45a2d286ce53475478056c0a3
1 // RUN: %llvmgcc -S %s -o - | llvm-as -o /dev/null
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <sys/types.h>
7 int
8 main(int argc, char** argv)
10 char c1;
11 short s1, ssf1, ssd1;
12 unsigned char ubs0;
13 signed char bs0;
14 unsigned char ubc0, uc2;
15 unsigned short us2, usf1, usd1;
16 int ic3, is3, sif1, sid1;
17 unsigned int uic4, uis4, uif1, uid1;
18 long slf1, sld1;
19 unsigned long ulf1, uld1;
20 float f1;
21 double d1;
23 /* Test integer to integer conversions */
25 c1 = (char) (argc >= 2)? atoi(argv[1]) : 0xff64; /* 100 = 'd' */
26 s1 = (short) (argc >= 3)? atoi(argv[2]) : -769; /* 0xf7ff = -769 */
28 ubc0 = (unsigned char) c1; /* 100 = 'd' */
29 ubs0 = (unsigned char) s1; /* 0xff = 255 */
30 bs0 = (signed char) s1; /* 0xff = -1 */
32 uc2 = (unsigned char) c1; /* 100 = 'd' */
33 us2 = (unsigned short) s1; /* 0xf7ff = 64767 */
35 ic3 = (int) c1; /* 100 = 'd' */
36 is3 = (int) s1; /* 0xfffff7ff = -769 */
38 uic4 = (unsigned int) c1; /* 100 = 'd' */
39 uis4 = (unsigned int) s1; /* 0xfffff7ff = 4294966527 */
41 printf("ubc0 = '%c'\n", ubc0);
42 printf("ubs0 = %u\n", ubs0);
43 printf("bs0 = %d\n", bs0);
44 printf("c1 = '%c'\n", c1);
45 printf("s1 = %d\n", s1);
46 printf("uc2 = '%c'\n", uc2);
47 printf("us2 = %u\n", us2);
48 printf("ic3 = '%c'\n", ic3);
49 printf("is3 = %d\n", is3);
50 printf("uic4 = '%c'\n", uic4);
51 printf("uis4 = %u\n", uis4);
53 /* Test floating-point to integer conversions */
54 f1 = (float) (argc >= 4)? atof(argv[3]) : 1.0;
55 d1 = (argc >= 5)? atof(argv[4]) : 2.0;
57 usf1 = (unsigned short) f1;
58 usd1 = (unsigned short) d1;
59 uif1 = (unsigned int) f1;
60 uid1 = (unsigned int) d1;
61 ulf1 = (unsigned long) f1;
62 uld1 = (unsigned long) d1;
64 ssf1 = (short) f1;
65 ssd1 = (short) d1;
66 sif1 = (int) f1;
67 sid1 = (int) d1;
68 slf1 = (long) f1;
69 sld1 = (long) d1;
71 printf("usf1 = %u\n", usf1);
72 printf("usd1 = %u\n", usd1);
73 printf("uif1 = %u\n", uif1);
74 printf("uid1 = %u\n", uid1);
75 printf("ulf1 = %u\n", ulf1);
76 printf("uld1 = %u\n", uld1);
78 printf("ssf1 = %d\n", ssf1);
79 printf("ssd1 = %d\n", ssd1);
80 printf("sif1 = %d\n", sif1);
81 printf("sid1 = %d\n", sid1);
82 printf("slf1 = %d\n", slf1);
83 printf("sld1 = %d\n", sld1);
85 return 0;