1 /* PR middle-end/30262 */
2 /* { dg-skip-if "asm statements do not work as expected" { rl78-*-* } "*" "" } */
3 extern void abort (void);
4 
5 int
foo(void)6 foo (void)
7 {
8   unsigned int x = 0;
9 
10   void nested (void)
11   {
12     x = 254;
13   }
14 
15   nested ();
16   asm volatile ("" :: "r" (x));
17   asm volatile ("" :: "m" (x));
18   asm volatile ("" :: "mr" (x));
19   asm volatile ("" : "=r" (x) : "0" (x));
20   asm volatile ("" : "=m" (x) : "m" (x));
21   return x;
22 }
23 
24 int
bar(void)25 bar (void)
26 {
27   unsigned int x = 0;
28 
29   void nested (void)
30   {
31     asm volatile ("" :: "r" (x));
32     asm volatile ("" :: "m" (x));
33     asm volatile ("" :: "mr" (x));
34     x += 4;
35     asm volatile ("" : "=r" (x) : "0" (x));
36     asm volatile ("" : "=m" (x) : "m" (x));
37   }
38 
39   nested ();
40   return x;
41 }
42 
43 int
baz(void)44 baz (void)
45 {
46   unsigned int x = 0;
47 
48   void nested (void)
49   {
50     void nested2 (void)
51     {
52       asm volatile ("" :: "r" (x));
53       asm volatile ("" :: "m" (x));
54       asm volatile ("" :: "mr" (x));
55       x += 4;
56       asm volatile ("" : "=r" (x) : "0" (x));
57       asm volatile ("" : "=m" (x) : "m" (x));
58     }
59     nested2 ();
60     nested2 ();
61   }
62 
63   nested ();
64   return x;
65 }
66 
67 int
main(void)68 main (void)
69 {
70   if (foo () != 254 || bar () != 4 || baz () != 8)
71     abort ();
72   return 0;
73 }
74