diff options
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/gimplify.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr21419.c | 15 |
4 files changed, 32 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fb66403..2d793e0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 42b8740..e5d50e2 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -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)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6146c23..e279840 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..f1e9cb9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr21419.c @@ -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" } */ +} + + |