aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-09-18 23:56:18 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-09-18 23:56:18 +0000
commit57b524174e514e6df90c7d973c43b78b5a5c5004 (patch)
treec6fd4b16dbf1978e9723b877dab3cfb61c21f280 /gcc
parentb534921ac08f8314a0d3330de3aef7b5588ea411 (diff)
downloadgcc-57b524174e514e6df90c7d973c43b78b5a5c5004.zip
gcc-57b524174e514e6df90c7d973c43b78b5a5c5004.tar.gz
gcc-57b524174e514e6df90c7d973c43b78b5a5c5004.tar.bz2
decl.c (layout_var_decl): Change prototype.
* 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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl.c34
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/crash11.C21
4 files changed, 45 insertions, 19 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 00038b5..599c7ff 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b1563cf..ed3e11e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 35bf27f..22efc7e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 0000000..535a6a2
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/crash11.C
@@ -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>;