re PR inline-asm/32109 (ICE with inline-asm and class with destructor)
authorJakub Jelinek <jakub@redhat.com>
Wed, 20 Jun 2007 06:37:17 +0000 (08:37 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 20 Jun 2007 06:37:17 +0000 (08:37 +0200)
PR inline-asm/32109
* gimplify.c (gimplify_asm_expr): Issue error if type is addressable
and !allows_mem.

* g++.dg/ext/asm10.C: New test.

From-SVN: r125874

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/asm10.C [new file with mode: 0644]

index 7b3e68d5bcadc1f2a22fe5fea8c5ff385f724dee..b73ef8135d58591a11302ae29b6d55f5b8a3321c 100644 (file)
@@ -1,5 +1,9 @@
 2007-06-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR inline-asm/32109
+       * gimplify.c (gimplify_asm_expr): Issue error if type is addressable
+       and !allows_mem.
+
        PR middle-end/32285
        * calls.c (precompute_arguments): Also precompute CALL_EXPR arguments
        if ACCUMULATE_OUTGOING_ARGS.
index 774af9adbf81b8b6920d046212137d50b57f1824..01ccaf02a823a3adf1cd03d96181858caac9c7da 100644 (file)
@@ -4122,6 +4122,19 @@ gimplify_asm_expr (tree *expr_p, tree *pre_p, tree *post_p)
       parse_input_constraint (&constraint, 0, 0, noutputs, 0,
                              oconstraints, &allows_mem, &allows_reg);
 
+      /* If we can't make copies, we can only accept memory.  */
+      if (TREE_ADDRESSABLE (TREE_TYPE (TREE_VALUE (link))))
+       {
+         if (allows_mem)
+           allows_reg = 0;
+         else
+           {
+             error ("impossible constraint in %<asm%>");
+             error ("non-memory input %d must stay in memory", i);
+             return GS_ERROR;
+           }
+       }
+
       /* If the operand is a memory input, it should be an lvalue.  */
       if (!allows_reg && allows_mem)
        {
index 20b44c827497f728d65c8972b6e2c6af1400df9e..0cefc19892feb60a44165ed9f0842ace639a5b13 100644 (file)
@@ -1,5 +1,8 @@
 2007-06-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR inline-asm/32109
+       * g++.dg/ext/asm10.C: New test.
+
        PR middle-end/32285
        * gcc.c-torture/execute/20070614-1.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/ext/asm10.C b/gcc/testsuite/g++.dg/ext/asm10.C
new file mode 100644 (file)
index 0000000..b95027c
--- /dev/null
@@ -0,0 +1,14 @@
+// PR inline-asm/32109
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct A { int i[3]; ~A (); };
+struct A a;
+struct B { struct A c; int i; B (); } b;
+
+B::B ()
+{
+  __asm ("" : : "r" (a));      // { dg-error "impossible constraint|non-memory input" }
+  __asm ("" : : "r" (b.c));    // { dg-error "impossible constraint|non-memory input" }
+  __asm ("" : : "r" (c));      // { dg-error "impossible constraint|non-memory input" }
+}