re PR testsuite/59043 (FAIL: (gcc|++).dg/pubtypes* scan-assembler long.*Length of...
[gcc.git] / gcc / testsuite / gcc.dg / pubtypes-3.c
1 /* { dg-do compile { target *-*-darwin* } } */
2 /* { dg-options "-O0 -gdwarf-2 -dA" } */
3 /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */
4 /* { dg-final { scan-assembler "__debug_pubtypes" } } */
5 /* { dg-final { scan-assembler "long+\[ \t\]+0x13b+\[ \t\]+\[#;]+\[ \t\]+Pub Info Length" } } */
6 /* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
7 /* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
8 /* { dg-final { scan-assembler-not "\"list_name_type\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
9
10 #include <stdlib.h>
11 #include <stdio.h>
12
13 struct used_struct
14 {
15 int key;
16 char *name;
17 };
18
19 struct unused_struct
20 {
21 int key1;
22 int f2;
23 double f3;
24 char *f4;
25 struct unused_struct *next;
26 };
27
28 void
29 foo (struct used_struct *list)
30 {
31 enum list_name_type {
32 boy_name,
33 girl_name,
34 unknown
35 };
36
37 int b_count = 0;
38 int g_count = 0;
39 int i;
40 enum list_name_type *enum_list;
41
42 enum_list = (enum list_name_type *) malloc (10 * sizeof (enum list_name_type));
43
44 for (i = 0; i < 10; i++)
45 {
46 if (strncmp (list[i].name, "Alice", 5) == 0)
47 {
48 enum_list[i] = girl_name;
49 g_count++;
50 }
51 else if (strncmp (list[i].name, "David", 5) == 0)
52 {
53 enum_list[i] = boy_name;
54 b_count++;
55 }
56 else
57 enum_list[i] = unknown;
58 }
59
60 }
61
62 int
63 main (int argc, char **argv)
64 {
65 int i;
66 struct used_struct *my_list;
67
68 my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct));
69
70 for (i = 0; i < 10; i++)
71 {
72 my_list[i].key = i;
73 my_list[i].name = (char *) malloc (11);
74 sprintf (my_list[i].name, "Alice_%d", i);
75 }
76
77 foo (my_list);
78
79 for (i = 0; i < 10; i++)
80 fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name);
81
82 return 0;
83 }