aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/20070507-1.c
blob: 2884d1aa8d8d8a38cdafdfc038df9e38fd47da63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* This failed on s390x due to bug in loop.c.
   loop.c failed to remove a REG_EQUAL note when
   hoisting an insn from a loop body.  */

/* { dg-options "-O3 -fPIC" } */
/* { dg-do run { target fpic } } */

typedef __SIZE_TYPE__ size_t;
int memcmp(const void *s1, const void *s2, size_t n);

typedef struct
{
  char name[30];
  int a;
} LOCAL;

int global = 0;
int sy = 1;
int subroutine_offset;

LOCAL local = { "local", 0 };
LOCAL keywords = { "keywords", 1 };
int local_table = 0;
int keywords_table = 0;

void __attribute__((noinline)) bar (char *p_buffer)
{
  p_buffer[255] = 1;
}

int __attribute__((noinline)) foo (char *p_str1)
{
  global = 1;
  return 1;
}

int __attribute__((noinline)) loop_next (int *p_table, char *p_table_head)
{
  static loop_next = 0;

  if (loop_next == 1)
    return 1;

  loop_next = 1;
  return 0;
}

int
main ()
{
  char buffer[256];
  int ende = 0;
  int index;
  int local_base = 2;

  keywords.a = 1;
  for (sy = 0;; sy++)
    {
      for (index = 1;;)
	{
	  bar (buffer);
	  if (buffer[sy] != 0)
	    {
	      ende = 1;
	      break;
	    };
	  if (foo (buffer))
	    {
	      keywords.a += index - 1;
	      break;
	    }
	  index++;
	}
      if (ende)
	break;
    }

  subroutine_offset = 0;

  for (;;)
    {
      if (loop_next (&keywords_table, (char*)&keywords))
	break;

      if ((!memcmp (keywords.name, "+++", 3)))
	local_base = 100;
      else
	local_base = 0;

      if ((!memcmp (keywords.name, "+++", 3)))
	subroutine_offset += local_table;

      for (;;)
	{
	  if (loop_next (&local_table, (char*)&local))
	    break;;
	  if ((local.a == 0))
	    continue;;
	  foo (local.name);
	}
    }
  return 0;
}