1 /* { dg-do compile } */
2 /* { dg-require-effective-target avr_tiny } */
3 /* { dg-options "-mabsdata" } */
4 
5 typedef struct
6 {
7   char a, b, c;
8 } abc_t;
9 
10 extern char varA;
11 extern char varB;
12 extern const char varC __attribute__((progmem));
13 
14 extern int arrayA[];
15 extern int arrayB[];
16 extern char arrayC[] __attribute__((address(0x80)));
17 extern char arrayD[] __attribute__((address(0xc0)));
18 
19 extern abc_t abc;
20 
get_1(void)21 char get_1 (void)
22 {
23   return varA;
24 }
25 
get_2(void)26 int get_2 (void)
27 {
28   return arrayA[3];
29 }
30 
get_3(void)31 char get_3 (void)
32 {
33   return abc.a + abc.b + abc.c;
34 }
35 
get_4(void)36 char get_4 (void)
37 {
38   return varC;
39 }
40 
put_1(char b)41 void put_1 (char b)
42 {
43   varB = b;
44 }
45 
put_2(int b)46 void put_2 (int b)
47 {
48   arrayB[3] = b;
49 }
50 
put_3(void)51 void put_3 (void)
52 {
53   abc.a = abc.b = abc.c = 0;
54 }
55 
put_4(void)56 void put_4 (void)
57 {
58   arrayC[0] = arrayC[1] = arrayC[2] = 0;
59 }
60 
put_5(void)61 void put_5 (void)
62 {
63   arrayD[0] = 0;
64 }
65 
66 /* { dg-final { scan-assembler "lds r\[0-9\]+,varA" } } */
67 /* { dg-final { scan-assembler "lds r\[0-9\]+,arrayA\\+6" } } */
68 /* { dg-final { scan-assembler "lds r\[0-9\]+,arrayA\\+6\\+1" } } */
69 /* { dg-final { scan-assembler "lds r\[0-9\]+,abc" } } */
70 /* { dg-final { scan-assembler "lds r\[0-9\]+,abc\\+1" } } */
71 /* { dg-final { scan-assembler "lds r\[0-9\]+,abc\\+2" } } */
72 
73 /* { dg-final { scan-assembler "sts varB," } } */
74 /* { dg-final { scan-assembler "sts arrayB\\+6," } } */
75 /* { dg-final { scan-assembler "sts arrayB\\+6\\+1," } } */
76 /* { dg-final { scan-assembler "sts arrayC," } } */
77 /* { dg-final { scan-assembler "sts arrayC\\+1," } } */
78 /* { dg-final { scan-assembler "sts arrayC\\+2," } } */
79 
80 /* { dg-final { scan-assembler "sts abc," } } */
81 /* { dg-final { scan-assembler "sts abc\\+1," } } */
82 /* { dg-final { scan-assembler "sts abc\\+2," } } */
83 
84 /* { dg-final { scan-assembler-not "lds r\[0-9\]+,varC" } } */
85 /* { dg-final { scan-assembler-not "sts arrayD," } } */
86