]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/c/struct_types/main.c
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / c / struct_types / main.c
1 //===-- main.c --------------------------------------------------*- 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 struct things_to_sum {
11     int a;
12     int b;
13     int c;
14 };
15
16 int sum_things(struct things_to_sum tts)
17 {
18     return tts.a + tts.b + tts.c;
19 }
20
21 int main (int argc, char const *argv[])
22 {
23     struct point_tag {
24         int x;
25         int y;
26         char padding[0];
27     }; //% self.expect("frame variable pt.padding[0]", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["pt.padding[0] = "])
28        //% self.expect("frame variable pt.padding[1]", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["pt.padding[1] = "])
29        //% self.expect("expression -- (pt.padding[0])", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["(char)", " = "])
30        //% self.expect("image lookup -t point_tag", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ['padding[]']) # Once rdar://problem/12566646 is fixed, this should display correctly
31
32     struct rect_tag {
33         struct point_tag bottom_left;
34         struct point_tag top_right;
35     };
36     struct point_tag pt = { 2, 3, {} };
37     struct rect_tag rect = {{1, 2, {}}, {3, 4, {}}};
38     struct things_to_sum tts = { 2, 3, 4 };
39
40     int sum = sum_things(tts); //% self.expect("expression -- &pt == (struct point_tag*)0", substrs = ['false'])
41                                //% self.expect("expression -- sum_things(tts)", substrs = ['9'])
42     return 0; 
43 }