• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <stdint.h>
13 
14 typedef float RealNumber; // should show as char
15 typedef RealNumber Temperature; // should show as float
16 typedef RealNumber Speed; // should show as hex
17 
18 typedef int Counter; // should show as int
19 typedef int BitField; // should show as hex
20 
21 typedef BitField SignalMask; // should show as hex
22 typedef BitField Modifiers; // should show as hex
23 
24 typedef Counter Accumulator; // should show as int
25 
26 typedef int Type1; // should show as char
27 typedef Type1 Type2; // should show as hex
28 typedef Type2 Type3; // should show as char
29 typedef Type3 Type4; // should show as char
30 
31 typedef int ChildType; // should show as int
32 typedef int AnotherChildType; // should show as int
33 
34 struct Point {
35     int x;
36     int y;
PointPoint37     Point(int X = 3, int Y = 2) : x(X), y(Y) {}
38 };
39 
40 typedef float ShowMyGuts;
41 
42 struct i_am_cool
43 {
44 	int integer;
45 	ShowMyGuts floating;
46 	char character;
i_am_cooli_am_cool47 	i_am_cool(int I, ShowMyGuts F, char C) :
48     integer(I), floating(F), character(C) {}
i_am_cooli_am_cool49 	i_am_cool() : integer(1), floating(2), character('3') {}
50 
51 };
52 
53 struct i_am_cooler
54 {
55 	i_am_cool first_cool;
56 	i_am_cool second_cool;
57 	ShowMyGuts floating;
58 
i_am_cooleri_am_cooler59 	i_am_cooler(int I1, int I2, float F1, float F2, char C1, char C2) :
60     first_cool(I1,F1,C1),
61     second_cool(I2,F2,C2),
62     floating((F1 + F2)/2) {}
63 };
64 
65 struct IUseCharStar
66 {
67 	const char* pointer;
IUseCharStarIUseCharStar68 	IUseCharStar() : pointer("Hello world") {}
69 };
70 
main(int argc,const char * argv[])71 int main (int argc, const char * argv[])
72 {
73 
74     int iAmInt = 1;
75     const float& IAmFloat = float(2.45);
76 
77     RealNumber RNILookChar = 3.14;
78     Temperature TMILookFloat = 4.97;
79     Speed SPILookHex = 5.55;
80 
81     Counter CTILookInt = 6;
82     BitField BFILookHex = 7;
83     SignalMask SMILookHex = 8;
84     Modifiers MFILookHex = 9;
85 
86     Accumulator* ACILookInt = new Accumulator(10);
87 
88     const Type1& T1ILookChar = 11;
89     Type2 T2ILookHex = 12;
90     Type3 T3ILookChar = 13;
91     Type4 T4ILookChar = 14;
92 
93     AnotherChildType AHILookInt = 15;
94 
95     Speed* SPPtrILookHex = new Speed(16);
96 
97     Point iAmSomewhere(4,6);
98 
99 	i_am_cool *cool_pointer = (i_am_cool*)malloc(sizeof(i_am_cool)*3);
100 	cool_pointer[0] = i_am_cool(3,-3.141592,'E');
101 	cool_pointer[1] = i_am_cool(0,-3.141592,'E');
102 	cool_pointer[2] = i_am_cool(0,-3.141592,'E');
103 
104     i_am_cool cool_array[5];
105 
106     cool_array[3].floating = 5.25;
107     cool_array[4].integer = 6;
108     cool_array[2].character = 'Q';
109 
110     int int_array[] = {1,2,3,4,5};
111 
112     IUseCharStar iEncapsulateCharStar;
113 
114     char  strarr[32] = "Hello world!";
115     char* strptr     = "Hello world!";
116 
117     i_am_cooler the_coolest_guy(1,2,3.14,6.28,'E','G');
118 
119     return 0; // Set break point at this line.
120 }
121 
122