OSDN Git Service

* pt.c (cur_stmt_expr): Move from tsubst_expr.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 12 Sep 2004 04:45:59 +0000 (04:45 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 12 Sep 2004 04:45:59 +0000 (04:45 +0000)
        (tsubst_expr) <case STMT_EXPR>: Move ...
        (tsubst_copy_and_build): ... here.

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

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

index 8e1f434..c8ba24d 100644 (file)
@@ -1,3 +1,10 @@
+2004-09-11  Richard Henderson  <rth@redhat.com>
+
+       PR c++/17404
+        * pt.c (cur_stmt_expr): Move from tsubst_expr.
+        (tsubst_expr) <case STMT_EXPR>: Move ...
+        (tsubst_copy_and_build): ... here.
+
 2004-09-10  Zack Weinberg  <zack@codesourcery.com>
 
        * cp-tree.h (interface_only, interface_unknown): Delete declarations;
index 3bdcf06..0a6b773 100644 (file)
@@ -67,6 +67,11 @@ static GTY(()) tree current_tinst_level;
 
 static GTY(()) tree saved_access_scope;
 
+/* Live only within one (recursive) call to tsubst_expr.  We use
+   this to pass the statement expression node from the STMT_EXPR
+   to the EXPR_STMT that is its result.  */
+static tree cur_stmt_expr;
+
 /* A map from local variable declarations in the body of the template
    presently being instantiated to the corresponding instantiated
    local variables.  */
@@ -7790,11 +7795,6 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 static tree
 tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 {
-  /* Live only within one (recursive) call to tsubst_expr.  We use
-     this to pass the statement expression node from the STMT_EXPR
-     to the EXPR_STMT that is its result.  */
-  static tree cur_stmt_expr;
-
   tree stmt, tmp;
 
   if (t == NULL_TREE || t == error_mark_node)
@@ -7825,19 +7825,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
                                       args, complain, in_decl));
       break;
 
-    case STMT_EXPR:
-      {
-       tree old_stmt_expr = cur_stmt_expr;
-       tree stmt_expr = begin_stmt_expr ();
-
-       cur_stmt_expr = stmt_expr;
-       tsubst_expr (STMT_EXPR_STMT (t), args, complain, in_decl);
-       stmt_expr = finish_stmt_expr (stmt_expr, false);
-       cur_stmt_expr = old_stmt_expr;
-
-       return stmt_expr;
-      }
-
     case EXPR_STMT:
       tmp = tsubst_expr (EXPR_STMT_EXPR (t), args, complain, in_decl);
       if (EXPR_STMT_STMT_EXPR_RESULT (t))
@@ -8626,6 +8613,19 @@ tsubst_copy_and_build (tree t,
     case OFFSETOF_EXPR:
       return fold_offsetof (RECUR (TREE_OPERAND (t, 0)));
 
+    case STMT_EXPR:
+      {
+       tree old_stmt_expr = cur_stmt_expr;
+       tree stmt_expr = begin_stmt_expr ();
+
+       cur_stmt_expr = stmt_expr;
+       tsubst_expr (STMT_EXPR_STMT (t), args, complain, in_decl);
+       stmt_expr = finish_stmt_expr (stmt_expr, false);
+       cur_stmt_expr = old_stmt_expr;
+
+       return stmt_expr;
+      }
+
     default:
       return tsubst_copy (t, args, complain, in_decl);
     }
diff --git a/gcc/testsuite/g++.dg/template/stmtexpr1.C b/gcc/testsuite/g++.dg/template/stmtexpr1.C
new file mode 100644 (file)
index 0000000..a470ca8
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/17404
+// { dg-do compile }
+// { dg-options "" }
+
+template <int> void foo ()
+{
+  __builtin_expect  (({0;}), 1);
+}
+template void foo<1> ();