pt.c (tsubst_expr): Set DECL_TEMPLATE_INSTANTIATED for a catch paramter.
authorMark Mitchell <mark@codesourcery.com>
Fri, 8 Oct 1999 05:42:36 +0000 (05:42 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 8 Oct 1999 05:42:36 +0000 (05:42 +0000)
* pt.c (tsubst_expr): Set DECL_TEMPLATE_INSTANTIATED for a catch
paramter.

* semantics.c (expand_stmt): Don't pretend to have asmspecs for
local statics if we don't really have them.

* ir.texi: Improve documentation for STMT_EXPR.  Describe
CLEANUP_POINT_EXPR.

From-SVN: r29863

gcc/cp/ChangeLog
gcc/cp/ir.texi
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/g++.old-deja/g++.eh/tmpl6.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.other/static9.C [new file with mode: 0644]

index 45bde39..97f1698 100644 (file)
@@ -1,3 +1,14 @@
+1999-10-07  Mark Mitchell  <mark@codesourcery.com>
+
+       * pt.c (tsubst_expr): Set DECL_TEMPLATE_INSTANTIATED for a catch
+       paramter.
+       
+       * semantics.c (expand_stmt): Don't pretend to have asmspecs for
+       local statics if we don't really have them.
+
+       * ir.texi: Improve documentation for STMT_EXPR.  Describe
+       CLEANUP_POINT_EXPR.
+
 1999-10-07  Jason Merrill  <jason@yorick.cygnus.com>
 
        * class.c (build_vtable_entry_ref): Use finish_asm_stmt.
index dd7a569..fd21cf3 100644 (file)
@@ -1475,6 +1475,7 @@ The @code{WHILE_BODY} is the body of the loop.
 @tindex BIND_EXPR
 @tindex LOOP_EXPR
 @tindex EXIT_EXPR
+@tindex CLEANUP_POINT_EXPR
 @tindex ARRAY_REF
 
 The internal representation for expressions is for the most part quite
@@ -1824,7 +1825,19 @@ expression would normally appear.  The @code{STMT_EXPR} node represents
 such an expression.  The @code{STMT_EXPR_STMT} gives the statement
 contained in the expression; this is always a @code{COMPOUND_STMT}.  The
 value of the expression is the value of the last sub-statement in the
-@code{COMPOUND_STMT}.
+@code{COMPOUND_STMT}.  More precisely, the value is the value computed
+by the last @code{EXPR_STMT} in the outermost scope of the
+@code{COMPOUND_STMT}.  For example, in:
+@example
+(@{ 3; @})
+@end example
+the value is @code{3} while in:
+@example
+(@{ if (x) { 3; } @})
+@end example
+(represented by a nested @code{COMPOUND_STMT}), there is no value.  If
+the @code{STMT_EXPR} does not yield a value, it's type will be
+@code{void}.
 
 @item BIND_EXPR
 These nodes represent local blocks.  The first operand is a list of
@@ -1844,6 +1857,12 @@ These nodes represent conditional exits from the nearest enclosing
 non-zero, then the loop should be exited.  An @code{EXIT_EXPR} will only
 appear within a @code{LOOP_EXPR}.
 
+@item CLEANUP_POINT_EXPR
+These nodes represent full-expressions.  The single oeprand is an
+expression to evaluate.  Any destructor calls engendered by the creation
+of temporaries during the evaluation of that expression should be
+performed immediately after the expression is evaluated.
+
 @item CONSTRUCTOR
 These nodes represent the brace-enclosed initializers for a structure or
 array.  The first operand is reserved for use by the back-end.  The
index b4b9ba9..027e04a 100644 (file)
@@ -7424,6 +7424,10 @@ tsubst_expr (t, args, complain, in_decl)
          {
            decl = DECL_STMT_DECL (HANDLER_PARMS (t));
            decl = tsubst (decl, args, complain, in_decl);
+           /* Prevent instantiate_decl from trying to instantiate
+              this variable.  We've already done all that needs to be
+              done.  */
+           DECL_TEMPLATE_INSTANTIATED (decl) = 1;
          }
        else
          decl = NULL_TREE;
index da17d3b..5cdeb07 100644 (file)
@@ -2301,9 +2301,21 @@ expand_stmt (t)
                                          DECL_ANON_UNION_ELEMS (decl));
              }
            else if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
-             rest_of_decl_compilation 
-               (decl, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
-                /*top_level=*/0, /*at_end=*/0);
+             {
+               const char *asmspec = NULL;
+
+               if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
+                 {
+                   /* The only way this situaton can occur is if the
+                      user specified a name for this DECL using the
+                      `attribute' syntax.  */
+                   asmspec = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+                   DECL_ASSEMBLER_NAME (decl) = DECL_NAME (decl);
+                 }
+
+               rest_of_decl_compilation (decl, asmspec, 
+                                         /*top_level=*/0, /*at_end=*/0);
+             }
 
            resume_momentary (i);
          }
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/tmpl6.C b/gcc/testsuite/g++.old-deja/g++.eh/tmpl6.C
new file mode 100644 (file)
index 0000000..b5b79c8
--- /dev/null
@@ -0,0 +1,18 @@
+// Build don't link:
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+struct S
+{
+  int i;
+};
+
+template <class T>
+void f ()
+{
+  try {
+  } catch (S& s) {
+    s.i = 3;
+  }
+}
+
+template void f<int>();
diff --git a/gcc/testsuite/g++.old-deja/g++.other/static9.C b/gcc/testsuite/g++.old-deja/g++.other/static9.C
new file mode 100644 (file)
index 0000000..e1bb50b
--- /dev/null
@@ -0,0 +1,17 @@
+// Build don't link:
+// Origin: Ulrich Drepper <drepper@cygnus.com>
+
+struct st
+{
+  int a, b, c, d;
+};
+
+void g ()
+{
+  static const st i = { 0,1,2,3 };
+}
+
+void h ()
+{
+  static const st i = { 0,1,2,3 };
+}