]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/43690 (Internal compiler error detected by avr-gcc.)
authorJakub Jelinek <jakub@redhat.com>
Thu, 11 Nov 2010 20:36:49 +0000 (21:36 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 11 Nov 2010 20:36:49 +0000 (21:36 +0100)
Backport from mainline
2010-11-05  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/43690
* gimplify.c (gimplify_asm_expr): If a "m" input is a
{pre,post}{in,de}crement, fail.

* c-c++-common/pr43690.c: New test.

From-SVN: r166617

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr43690.c [new file with mode: 0644]

index 9d8f96922f2aa6742c6f37eddd3ca419e395fa91..d06874155c360772c4657cb5cef7fa5eeea70e80 100644 (file)
@@ -1,6 +1,12 @@
 2010-11-11  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
+       2010-11-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/43690
+       * gimplify.c (gimplify_asm_expr): If a "m" input is a
+       {pre,post}{in,de}crement, fail.
+
        2010-11-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/46165
index b4b65b4808ea9f39a6cc31066e399f38f85669f3..d85c033063cdb66b99a1a4197547a23f1e4fe5dd 100644 (file)
@@ -4995,6 +4995,13 @@ gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
       /* If the operand is a memory input, it should be an lvalue.  */
       if (!allows_reg && allows_mem)
        {
+         tree inputv = TREE_VALUE (link);
+         STRIP_NOPS (inputv);
+         if (TREE_CODE (inputv) == PREDECREMENT_EXPR
+             || TREE_CODE (inputv) == PREINCREMENT_EXPR
+             || TREE_CODE (inputv) == POSTDECREMENT_EXPR
+             || TREE_CODE (inputv) == POSTINCREMENT_EXPR)
+           TREE_VALUE (link) = error_mark_node;
          tret = gimplify_expr (&TREE_VALUE (link), pre_p, post_p,
                                is_gimple_lvalue, fb_lvalue | fb_mayfail);
          mark_addressable (TREE_VALUE (link));
index cf5f0b87e273c1c9c56d867a6e894647f9bdf5e0..43ff2fa456b207f69133f5a0cb48b19eaccfa3c3 100644 (file)
@@ -1,6 +1,11 @@
 2010-11-11  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
+       2010-11-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/43690
+       * c-c++-common/pr43690.c: New test.
+
        2010-11-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/46165
diff --git a/gcc/testsuite/c-c++-common/pr43690.c b/gcc/testsuite/c-c++-common/pr43690.c
new file mode 100644 (file)
index 0000000..67c6cb0
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR middle-end/43690 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void
+foo (char *x)
+{
+  asm ("" : : "m" (x++));      /* { dg-error "is not directly addressable" } */
+  asm ("" : : "m" (++x));      /* { dg-error "is not directly addressable" } */
+  asm ("" : : "m" (x--));      /* { dg-error "is not directly addressable" } */
+  asm ("" : : "m" (--x));      /* { dg-error "is not directly addressable" } */
+  asm ("" : : "m" (x + 1));    /* { dg-error "is not directly addressable" } */
+}