OSDN Git Service

gcc:
authorbonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Sep 2005 14:53:39 +0000 (14:53 +0000)
committerbonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Sep 2005 14:53:39 +0000 (14:53 +0000)
2005-09-29  Paolo Bonzini  <bonzini@gnu.org>

PR c/21419
* gimplify.c (gimplify_asm_expr): Raise an error if an output is
read-only.

testsuite:
2005-09-29  Paolo Bonzini  <bonzini@gnu.org>

        PR c/21419
        * gcc.dg/pr21419.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104774 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr21419.c [new file with mode: 0644]

index fb66403..2d793e0 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-29  Paolo Bonzini  <bonzini@gnu.org>
+
+       PR c/21419
+       * gimplify.c (gimplify_asm_expr): Raise an error if an output is
+       read-only.
+
 2005-09-29  Steven Bosscher  <stevenb@suse.de>
 
        PR tree-optimization/23911
index 42b8740..e5d50e2 100644 (file)
@@ -3544,6 +3544,12 @@ gimplify_asm_expr (tree *expr_p, tree *pre_p, tree *post_p)
       parse_output_constraint (&constraint, i, 0, 0,
                               &allows_mem, &allows_reg, &is_inout);
 
+      if (TYPE_READONLY (TREE_TYPE (TREE_VALUE (link))))
+       {
+         error ("invalid lvalue in asm output %d", i);
+         ret = GS_ERROR;
+       }
+
       if (!allows_reg && allows_mem)
        lang_hooks.mark_addressable (TREE_VALUE (link));
 
index 6146c23..e279840 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-29  Paolo Bonzini  <bonzini@gnu.org>
+
+        PR c/21419
+        * gcc.dg/pr21419.c: New test.
+
 2005-09-29  Steven Bosscher  <stevenb@suse.de>
 
        * gcc.dg/pr23911.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr21419.c b/gcc/testsuite/gcc.dg/pr21419.c
new file mode 100644 (file)
index 0000000..f1e9cb9
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+const int i = 0;
+
+void f(void)
+{
+  __asm__ __volatile__ ("" : "=m" (i)); /* { dg-error "invalid lvalue in asm output" } */
+
+}
+
+void g(const int set)
+{
+  __asm__ __volatile__ ("" : "=r" (set)); /* { dg-error "invalid lvalue in asm output" } */
+}
+
+