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\]+0x172+\[ \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 "\"list_name_type\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ 9/* { dg-final { scan-assembler "\"enum_list_array\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ 10/* { dg-final { scan-assembler "\"field_union\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */ 11 12#include <stdlib.h> 13#include <stdio.h> 14#include <string.h> 15 16struct used_struct 17{ 18 int key; 19 char *name; 20 union field_union 21 { 22 char u_c; 23 int u_i; 24 long u_l; 25 double u_d; 26 } u; 27}; 28 29struct unused_struct 30{ 31 int key1; 32 int f2; 33 double f3; 34 char *f4; 35 struct unused_struct *next; 36}; 37 38enum list_name_type { 39 boy_name, 40 girl_name, 41 unknown 42}; 43 44 45typedef enum list_name_type *enum_list_array; 46 47enum_list_array enum_list; 48 49void 50foo (struct used_struct *list) 51{ 52 int b_count = 0; 53 int g_count = 0; 54 int i; 55 56 enum_list = (enum_list_array) malloc (10 * sizeof (enum list_name_type)); 57 58 for (i = 0; i < 10; i++) 59 { 60 if (strncmp (list[i].name, "Alice", 5) == 0) 61 { 62 enum_list[i] = girl_name; 63 g_count++; 64 } 65 else if (strncmp (list[i].name, "David", 5) == 0) 66 { 67 enum_list[i] = boy_name; 68 b_count++; 69 } 70 else 71 enum_list[i] = unknown; 72 } 73 74} 75 76int 77main (int argc, char **argv) 78{ 79 int i; 80 struct used_struct *my_list; 81 82 my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct)); 83 84 for (i = 0; i < 10; i++) 85 { 86 my_list[i].key = i; 87 my_list[i].name = (char *) malloc (11); 88 sprintf (my_list[i].name, "Alice_%d", i); 89 } 90 91 foo (my_list); 92 93 for (i = 0; i < 10; i++) 94 fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name); 95 96 return 0; 97} 98