re PR c/21419 (Accepts writting to const via asm)

gcc:
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.

From-SVN: r104774
This commit is contained in:
Paolo Bonzini 2005-09-29 14:53:39 +00:00 committed by Paolo Bonzini
parent 090037799c
commit 02eb875fcf
4 changed files with 32 additions and 0 deletions

View 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

View 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));

View 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.

View File

@ -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" } */
}