OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [alias-11.c] - Blame information for rev 708

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do run } */
2
/* { dg-require-alias "" } */
3
/* { dg-options "-O2" } */
4
 
5
#include <stdio.h>
6
#include <stdlib.h>
7
#include <string.h>
8
 
9
typedef struct dw_cfi_struct
10
{
11
  struct dw_cfi_struct *dw_cfi_next;
12
  const char *dw_cfi_addr;
13
}
14
dw_cfi_node;
15
 
16
typedef struct dw_fde_struct
17
{
18
  const char *dw_fde_current_label;
19
  dw_cfi_node *dw_fde_cfi;
20
}
21
dw_fde_node;
22
 
23
dw_cfi_node *cie_cfi_head;
24
unsigned fde_table_in_use;
25
dw_fde_node *fde_table;
26
 
27
__inline__ void
28
add_cfi (dw_cfi_node **list_head, dw_cfi_node *cfi)
29
{
30
  dw_cfi_node **p;
31
 
32
  for (p = list_head; (*p) != ((void *)0); p = &(*p)->dw_cfi_next)
33
    ;
34
 
35
  *p = cfi;
36
}
37
 
38
__inline__ struct dw_cfi_struct *
39
new_cfi (void)
40
{
41
  dw_cfi_node *cfi = (dw_cfi_node *) malloc (sizeof (dw_cfi_node));
42
 
43
  memset (cfi, 0, sizeof (dw_cfi_node));
44
  return cfi;
45
}
46
 
47
char *
48
dwarf2out_cfi_label (void)
49
{
50
  static char label[20];
51
  static unsigned long label_num = 0;
52
 
53
  sprintf (label, "*.%s%u", "LCFI", (unsigned) (label_num++));
54
  return label;
55
}
56
 
57
void
58
add_fde_cfi (const char *label, dw_cfi_node *cfi)
59
{
60
  if (label)
61
    {
62
      dw_fde_node *fde = fde_table + fde_table_in_use - 1;
63
 
64
      if (*label == 0)
65
        label = dwarf2out_cfi_label ();
66
 
67
      if (fde->dw_fde_current_label == ((void *)0)
68
          || strcmp (label, fde->dw_fde_current_label))
69
        {
70
          dw_cfi_node *xcfi;
71
 
72
          fde->dw_fde_current_label = label = strdup (label);
73
 
74
          xcfi = new_cfi ();
75
          xcfi->dw_cfi_addr = label;
76
          add_cfi (&fde->dw_fde_cfi, xcfi);
77
        }
78
 
79
      add_cfi (&fde->dw_fde_cfi, cfi);
80
    }
81
  else
82
    add_cfi (&cie_cfi_head, cfi);
83
}
84
 
85
int
86
main ()
87
{
88
  dw_cfi_node *cfi;
89
  dw_fde_node *fde;
90
 
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);
97
 
98
  fde = &fde_table[0];
99
  cfi = fde->dw_fde_cfi;
100
 
101
  if (cfi == NULL)
102
    abort ();
103
 
104
  if (cfi->dw_cfi_addr == NULL)
105
    abort ();
106
 
107
  if (strcmp ("*.LCFI0", cfi->dw_cfi_addr))
108
    abort ();
109
 
110
  return 0;
111
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.