decl.c (layout_var_decl): Change prototype.
authorMark Mitchell <mark@codesourcery.com>
Sat, 18 Sep 1999 23:56:18 +0000 (23:56 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sat, 18 Sep 1999 23:56:18 +0000 (23:56 +0000)
* decl.c (layout_var_decl): Change prototype.  Call layout_decl
even when the declaration is external.
(cp_finish_decl): Adjust call to layout_var_decl.
* pt.c (tsubst_expr): Make sure to initialize stmt before using it.

From-SVN: r29504

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.other/crash11.C [new file with mode: 0644]

index 00038b54ae8719d4a8dfe783908dd5ca2f15a7e7..599c7ff254c545cf550d2d75db65133e9694f00a 100644 (file)
@@ -1,3 +1,10 @@
+1999-09-18  Mark Mitchell  <mark@codesourcery.com>
+
+       * decl.c (layout_var_decl): Change prototype.  Call layout_decl
+       even when the declaration is external.
+       (cp_finish_decl): Adjust call to layout_var_decl.
+       * pt.c (tsubst_expr): Make sure to initialize stmt before using it.
+
 1999-09-18  Martin von Loewis  <loewis@informatik.hu-berlin.de>
 
        * typeck.c (get_member_function_from_ptrfunc): Always consider
index b1563cf2f948f4978ac97ee0c1a2e94855c40095..ed3e11e921d06bac2584ecacd550f80457e9f679 100644 (file)
@@ -166,7 +166,7 @@ static tree make_label_decl PROTO((tree, int));
 static void pop_label PROTO((tree));
 static void pop_labels PROTO((tree));
 static void maybe_deduce_size_from_array_init PROTO((tree, tree));
-static tree layout_var_decl PROTO((tree, tree));
+static void layout_var_decl PROTO((tree));
 static void maybe_commonize_var PROTO((tree));
 static tree check_initializer PROTO((tree, tree));
 static void make_rtl_for_nonlocal_decl PROTO((tree, tree, const char *));
@@ -7088,23 +7088,23 @@ maybe_deduce_size_from_array_init (decl, init)
 }
 
 /* Set DECL_SIZE, DECL_ALIGN, etc. for DECL (a VAR_DECL), and issue
-   any appropriate error messages regarding the layout.  INIT is a
-   the initializer for DECL; returns a modified version.  */
+   any appropriate error messages regarding the layout.  */
 
-static tree
-layout_var_decl (decl, init)
+static void
+layout_var_decl (decl)
      tree decl;
-     tree init;
 {
-  tree ttype = target_type (TREE_TYPE (decl));
-
-  /* If we haven't already layed out this declaration, and we know its
-     type, do so now.  Note that we must not call complete type for an
-     external object because it's type might involve templates that we
-     are not supposed to isntantiate yet.  */
-  if (!DECL_EXTERNAL (decl)  
-      && DECL_SIZE (decl) == NULL_TREE
-      && TYPE_SIZE (complete_type (TREE_TYPE (decl))) != NULL_TREE)
+  tree type = TREE_TYPE (decl);
+  tree ttype = target_type (type);
+
+  /* If we haven't already layed out this declaration, do so now.
+     Note that we must not call complete type for an external object
+     because it's type might involve templates that we are not
+     supposed to isntantiate yet.  (And it's perfectly legal to say 
+     `extern X x' for some incomplete type `X'.)  */
+  if (!DECL_EXTERNAL (decl))
+    complete_type (type);
+  if (!DECL_SIZE (decl)&& TYPE_SIZE (type))
     layout_decl (decl, 0);
 
   if (!DECL_EXTERNAL (decl) && DECL_SIZE (decl) == NULL_TREE)
@@ -7131,8 +7131,6 @@ layout_var_decl (decl, init)
       else
        cp_error ("storage size of `%D' isn't constant", decl);
     }
-
-  return init;
 }
 
 /* If a local static variable is declared in an inline function, or if
@@ -7746,7 +7744,7 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
     end_temporary_allocation ();
 
   if (TREE_CODE (decl) == VAR_DECL)
-    init = layout_var_decl (decl, init);
+    layout_var_decl (decl);
 
   /* Output the assembler code and/or RTL code for variables and functions,
      unless the type is an undefined structure or union.
index 35bf27f9da0cb44d110a3b44d20382ba40b43f2b..22efc7e1df3cf0542eb36a25a5683254e47e4b6d 100644 (file)
@@ -7446,7 +7446,7 @@ tsubst_expr (t, args, complain, in_decl)
       prep_stmt (t);
       if (CLEANUP_P (t))
        {
-         begin_try_block ();
+         stmt = begin_try_block ();
          tsubst_expr (TRY_STMTS (t), args, complain, in_decl);
          finish_cleanup_try_block (stmt);
          finish_cleanup (tsubst_expr (TRY_HANDLERS (t), args,
diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash11.C b/gcc/testsuite/g++.old-deja/g++.other/crash11.C
new file mode 100644 (file)
index 0000000..535a6a2
--- /dev/null
@@ -0,0 +1,21 @@
+// Origin: Alfred Minarik <a8601248@unet.univie.ac.at>
+// Build don't link:
+
+template <typename T>
+struct allocator
+{
+  typedef int size_type;
+};
+
+template <typename T>
+struct string
+{
+  typedef typename allocator<T>::size_type size_type;
+
+  static size_type size;
+
+  size_type
+  max_size() const { return size; }
+};
+
+template string <char>;