1 // PR optimization/5547
2 // This testcase caused ICE on IA-32, since DWARF-2 was unable
3 // to emit location expression for parameter a of operator+.
4 // { dg-do compile { target fpic } }
5 // { dg-options "-fpic" }
6 
7 struct A { char *s; };
8 
9 inline A operator+ (char a, const A &b)
10 {
11   A s;
12   s.s = new char[12];
13   s.s[0] = a;
14   return s;
15 }
16 
17 int b (const A &);
18 
test1(const A & x,int y)19 void test1 (const A &x, int y)
20 {
21   int j = b ("012345"[y] + x);
22   for (int i = 0; i < y; i++);
23 }
24 
test2(const A & x,int y)25 void test2 (const A &x, int y)
26 {
27   int j = b ("012345678"[y + 2] + x);
28   for (int i = 0; i < y; i++);
29 }
30 
test3(const A & x,int y)31 void test3 (const A &x, int y)
32 {
33   int j = b ("012345678"[y - 6] + x);
34   for (int i = 0; i < y; i++);
35 }
36 
test4(const A & x,int y)37 void test4 (const A &x, int y)
38 {
39   int j = b ("012345678"[2 * y - 10] + x);
40   for (int i = 0; i < y; i++);
41 }
42 
test5(const A & x,int y)43 void test5 (const A &x, int y)
44 {
45   int j = b ("012345678"[4 * y] + x);
46   for (int i = 0; i < y; i++);
47 }
48