modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/20061220-1.c (about) 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 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 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 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 68 main (void) 69 { 70 if (foo () != 254 || bar () != 4 || baz () != 8) 71 abort (); 72 return 0; 73 }