2014-08-04 Ed Schonberg <schonberg@adacore.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / pubtypes-3.c
blobf4b0468ab199e2b3f8eef75903537e7ea841bc67
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>
13 struct used_struct
15 int key;
16 char *name;
19 struct unused_struct
21 int key1;
22 int f2;
23 double f3;
24 char *f4;
25 struct unused_struct *next;
28 void
29 foo (struct used_struct *list)
31 enum list_name_type {
32 boy_name,
33 girl_name,
34 unknown
37 int b_count = 0;
38 int g_count = 0;
39 int i;
40 enum list_name_type *enum_list;
42 enum_list = (enum list_name_type *) malloc (10 * sizeof (enum list_name_type));
44 for (i = 0; i < 10; i++)
46 if (strncmp (list[i].name, "Alice", 5) == 0)
48 enum_list[i] = girl_name;
49 g_count++;
51 else if (strncmp (list[i].name, "David", 5) == 0)
53 enum_list[i] = boy_name;
54 b_count++;
56 else
57 enum_list[i] = unknown;
62 int
63 main (int argc, char **argv)
65 int i;
66 struct used_struct *my_list;
68 my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct));
70 for (i = 0; i < 10; i++)
72 my_list[i].key = i;
73 my_list[i].name = (char *) malloc (11);
74 sprintf (my_list[i].name, "Alice_%d", i);
77 foo (my_list);
79 for (i = 0; i < 10; i++)
80 fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name);
82 return 0;