Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.dg / alias-11.c
blob36175d7c25a80256b68c8b07eae3707fe17f742e
1 /* { dg-do run } */
2 /* { dg-require-alias "" } */
3 /* { dg-options "-O2" } */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
9 typedef struct dw_cfi_struct
11 struct dw_cfi_struct *dw_cfi_next;
12 const char *dw_cfi_addr;
14 dw_cfi_node;
16 typedef struct dw_fde_struct
18 const char *dw_fde_current_label;
19 dw_cfi_node *dw_fde_cfi;
21 dw_fde_node;
23 dw_cfi_node *cie_cfi_head;
24 unsigned fde_table_in_use;
25 dw_fde_node *fde_table;
27 __inline__ void
28 add_cfi (dw_cfi_node **list_head, dw_cfi_node *cfi)
30 dw_cfi_node **p;
32 for (p = list_head; (*p) != ((void *)0); p = &(*p)->dw_cfi_next)
35 *p = cfi;
38 __inline__ struct dw_cfi_struct *
39 new_cfi (void)
41 dw_cfi_node *cfi = (dw_cfi_node *) malloc (sizeof (dw_cfi_node));
43 memset (cfi, 0, sizeof (dw_cfi_node));
44 return cfi;
47 char *
48 dwarf2out_cfi_label (void)
50 static char label[20];
51 static unsigned long label_num = 0;
53 sprintf (label, "*.%s%u", "LCFI", (unsigned) (label_num++));
54 return label;
57 void
58 add_fde_cfi (const char *label, dw_cfi_node *cfi)
60 if (label)
62 dw_fde_node *fde = fde_table + fde_table_in_use - 1;
64 if (*label == 0)
65 label = dwarf2out_cfi_label ();
67 if (fde->dw_fde_current_label == ((void *)0)
68 || strcmp (label, fde->dw_fde_current_label))
70 dw_cfi_node *xcfi;
72 fde->dw_fde_current_label = label = strdup (label);
74 xcfi = new_cfi ();
75 xcfi->dw_cfi_addr = label;
76 add_cfi (&fde->dw_fde_cfi, xcfi);
79 add_cfi (&fde->dw_fde_cfi, cfi);
81 else
82 add_cfi (&cie_cfi_head, cfi);
85 int
86 main ()
88 dw_cfi_node *cfi;
89 dw_fde_node *fde;
91 fde_table_in_use = 1;
92 fde_table = (dw_fde_node *) realloc (fde_table,
93 sizeof (dw_fde_node));
94 memset (fde_table, 0, sizeof (dw_fde_node));
95 cfi = new_cfi ();
96 add_fde_cfi ("", cfi);
98 fde = &fde_table[0];
99 cfi = fde->dw_fde_cfi;
101 if (cfi == NULL)
102 abort ();
104 if (cfi->dw_cfi_addr == NULL)
105 abort ();
107 if (strcmp ("*.LCFI0", cfi->dw_cfi_addr))
108 abort ();
110 return 0;