1 /* { dg-do compile { target nios2-*-linux-gnu } } */
2 /* { dg-options "-O2 -fpic" } */
3 /* { dg-final { scan-assembler-not "ldw\tr., %lo" } } */
4 /* { dg-final { scan-assembler-not "stw\tr., %lo" } } */
5 
6 /* Check that address transformations for symbolic constants do NOT
7    apply to code compiled with -fPIC, which requires references to
8    go through the GOT pointer (r22) instead.  */
9 
10 #define TYPE int
11 
12 struct ss
13 {
14   TYPE x1,x2;
15 };
16 
17 extern TYPE S1;
18 extern TYPE S2[];
19 
20 extern struct ss S3;
21 extern struct ss S4[];
22 
addr1(void)23 TYPE *addr1 (void) { return &S1; }
get1(void)24 TYPE get1 (void) { return S1; }
set1(TYPE value)25 void set1 (TYPE value) { S1 = value; }
26 
addr2(int i)27 TYPE *addr2 (int i) { return &(S2[i]); }
get2(int i)28 TYPE get2 (int i) { return S2[i]; }
set2(int i,TYPE value)29 void set2 (int i, TYPE value) { S2[i] = value; }
30 
addr3(void)31 TYPE *addr3 (void) { return &(S3.x2); }
get3(void)32 TYPE get3 (void) { return S3.x2; }
set3(TYPE value)33 void set3 (TYPE value) { S3.x2 = value; }
34 
addr4(int i)35 TYPE *addr4 (int i) { return &(S4[i].x2); }
get4(int i)36 TYPE get4 (int i) { return S4[i].x2; }
set4(int i,TYPE value)37 void set4 (int i, TYPE value) { S4[i].x2 = value; }
38 
39