Fix PR4948 (and a leak): by not destroying the DwarfException
[llvm/avr.git] / test / FrontendC / 2002-07-14-MiscListTests.c
blob4a5459ad7131e2e2411c9758f55922ec140c3f5f
1 // RUN: %llvmgcc -S %s -o - | llvm-as -o /dev/null
3 // Test list stuff
5 void *malloc(unsigned);
7 // Test opaque structure support. the list type is defined later
8 struct list;
10 struct list *PassThroughList(struct list *L) {
11 return L;
15 // Recursive data structure tests...
17 typedef struct list {
18 int Data;
19 struct list *Next;
20 } list;
22 list *Data;
24 void foo() {
25 static int Foo = 0; // Test static local variable
26 Foo += 1; // Increment static variable
28 Data = (list*)malloc(12); // This is not a proper list allocation
31 extern list ListNode1;
32 list ListNode3 = { 4, 0 };
33 list ListNode2 = { 3, &ListNode3 };
34 list ListNode0 = { 1, &ListNode1 };
35 list ListNode1 = { 2, &ListNode2 };
38 list ListArray[10];
40 // Iterative insert fn
41 void InsertIntoListTail(list **L, int Data) {
42 while (*L)
43 L = &(*L)->Next;
44 *L = (list*)malloc(sizeof(list));
45 (*L)->Data = Data;
46 (*L)->Next = 0;
49 // Recursive list search fn
50 list *FindData(list *L, int Data) {
51 if (L == 0) return 0;
52 if (L->Data == Data) return L;
53 return FindData(L->Next, Data);
56 void foundIt(void);
58 // Driver fn...
59 void DoListStuff() {
60 list *MyList = 0;
61 InsertIntoListTail(&MyList, 100);
62 InsertIntoListTail(&MyList, 12);
63 InsertIntoListTail(&MyList, 42);
64 InsertIntoListTail(&MyList, 1123);
65 InsertIntoListTail(&MyList, 1213);
67 if (FindData(MyList, 75)) foundIt();
68 if (FindData(MyList, 42)) foundIt();
69 if (FindData(MyList, 700)) foundIt();