PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / pubtypes-3.c
blob6fa1940c6068d681993c5a67ad439d80b4bb9774
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" } } */
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
14 struct used_struct
16 int key;
17 char *name;
20 struct unused_struct
22 int key1;
23 int f2;
24 double f3;
25 char *f4;
26 struct unused_struct *next;
29 void
30 foo (struct used_struct *list)
32 enum list_name_type {
33 boy_name,
34 girl_name,
35 unknown
38 int b_count = 0;
39 int g_count = 0;
40 int i;
41 enum list_name_type *enum_list;
43 enum_list = (enum list_name_type *) malloc (10 * sizeof (enum list_name_type));
45 for (i = 0; i < 10; i++)
47 if (strncmp (list[i].name, "Alice", 5) == 0)
49 enum_list[i] = girl_name;
50 g_count++;
52 else if (strncmp (list[i].name, "David", 5) == 0)
54 enum_list[i] = boy_name;
55 b_count++;
57 else
58 enum_list[i] = unknown;
63 int
64 main (int argc, char **argv)
66 int i;
67 struct used_struct *my_list;
69 my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct));
71 for (i = 0; i < 10; i++)
73 my_list[i].key = i;
74 my_list[i].name = (char *) malloc (11);
75 sprintf (my_list[i].name, "Alice_%d", i);
78 foo (my_list);
80 for (i = 0; i < 10; i++)
81 fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name);
83 return 0;