OSDN Git Service

PR c++/24761
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 12 Nov 2005 20:42:23 +0000 (20:42 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 12 Nov 2005 20:42:23 +0000 (20:42 +0000)
* pt.c (tsubst_copy_asm_operands): New function.
(tsubst_expr) <case ASM_EXPR>: Use it.

* g++.dg/template/asm1.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/asm1.C [new file with mode: 0644]

index bcbddc7..5736a0d 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/24761
+       * pt.c (tsubst_copy_asm_operands): New function.
+       (tsubst_expr) <case ASM_EXPR>: Use it.
+
 2005-11-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/19450
index c2fc36f..63123c4 100644 (file)
@@ -8136,6 +8136,39 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
     }
 }
 
+/* Like tsubst_copy_and_build, but unshare TREE_LIST nodes.  */
+
+static tree
+tsubst_copy_asm_operands (tree t, tree args, tsubst_flags_t complain,
+                         tree in_decl)
+{
+#define RECUR(t) tsubst_copy_asm_operands (t, args, complain, in_decl)
+
+  tree purpose, value, chain;
+
+  if (t == NULL)
+    return t;
+
+  if (TREE_CODE (t) != TREE_LIST)
+    return tsubst_copy_and_build (t, args, complain, in_decl,
+                                 /*function_p=*/false);
+
+  if (t == void_list_node)
+    return t;
+
+  purpose = TREE_PURPOSE (t);
+  if (purpose)
+    purpose = RECUR (purpose);
+  value = TREE_VALUE (t);
+  if (value)
+    value = RECUR (value);
+  chain = TREE_CHAIN (t);
+  if (chain && chain != void_type_node)
+    chain = RECUR (chain);
+  return tree_cons (purpose, value, chain);
+#undef RECUR
+}
+
 /* Like tsubst_copy for expressions, etc. but also does semantic
    processing.  */
 
@@ -8353,9 +8386,9 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
       tmp = finish_asm_stmt
        (ASM_VOLATILE_P (t),
         tsubst_expr (ASM_STRING (t), args, complain, in_decl),
-        tsubst_expr (ASM_OUTPUTS (t), args, complain, in_decl),
-        tsubst_expr (ASM_INPUTS (t), args, complain, in_decl),
-        tsubst_expr (ASM_CLOBBERS (t), args, complain, in_decl));
+        tsubst_copy_asm_operands (ASM_OUTPUTS (t), args, complain, in_decl),
+        tsubst_copy_asm_operands (ASM_INPUTS (t), args, complain, in_decl),
+        tsubst_copy_asm_operands (ASM_CLOBBERS (t), args, complain, in_decl));
       {
        tree asm_expr = tmp;
        if (TREE_CODE (asm_expr) == CLEANUP_POINT_EXPR)
index 9545e76..5500af1 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/24761
+       * g++.dg/template/asm1.C: New test.
+
 2005-11-12  Steven G. Kargl  <kargls@comcast.net>
 
        PR libgfortran/24787
diff --git a/gcc/testsuite/g++.dg/template/asm1.C b/gcc/testsuite/g++.dg/template/asm1.C
new file mode 100644 (file)
index 0000000..741759f
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/24761
+// { dg-do compile }
+
+template <int>
+int f (int i)
+{
+  asm ("# %0 %1" : "+r" (i));
+  return i;
+}
+
+int main ()
+{
+  return f<0> (0) + f<1> (0);
+}