summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/20061220-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/20061220-1.c')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20061220-1.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/20061220-1.c b/gcc/testsuite/gcc.c-torture/execute/20061220-1.c
new file mode 100644
index 000000000..188f92cfc
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20061220-1.c
@@ -0,0 +1,72 @@
+/* PR middle-end/30262 */
+extern void abort (void);
+
+int
+foo (void)
+{
+ unsigned int x = 0;
+
+ void nested (void)
+ {
+ x = 254;
+ }
+
+ nested ();
+ asm volatile ("" :: "r" (x));
+ asm volatile ("" :: "m" (x));
+ asm volatile ("" :: "mr" (x));
+ asm volatile ("" : "=r" (x) : "0" (x));
+ asm volatile ("" : "=m" (x) : "m" (x));
+ return x;
+}
+
+int
+bar (void)
+{
+ unsigned int x = 0;
+
+ void nested (void)
+ {
+ asm volatile ("" :: "r" (x));
+ asm volatile ("" :: "m" (x));
+ asm volatile ("" :: "mr" (x));
+ x += 4;
+ asm volatile ("" : "=r" (x) : "0" (x));
+ asm volatile ("" : "=m" (x) : "m" (x));
+ }
+
+ nested ();
+ return x;
+}
+
+int
+baz (void)
+{
+ unsigned int x = 0;
+
+ void nested (void)
+ {
+ void nested2 (void)
+ {
+ asm volatile ("" :: "r" (x));
+ asm volatile ("" :: "m" (x));
+ asm volatile ("" :: "mr" (x));
+ x += 4;
+ asm volatile ("" : "=r" (x) : "0" (x));
+ asm volatile ("" : "=m" (x) : "m" (x));
+ }
+ nested2 ();
+ nested2 ();
+ }
+
+ nested ();
+ return x;
+}
+
+int
+main (void)
+{
+ if (foo () != 254 || bar () != 4 || baz () != 8)
+ abort ();
+ return 0;
+}