From 73b8a26bf3cb3730d6888cb56b798a0ce6b8ba6b Mon Sep 17 00:00:00 2001 From: mmitchel Date: Sat, 18 Sep 1999 23:56:18 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29504 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 7 ++++++ gcc/cp/decl.c | 34 ++++++++++++-------------- gcc/cp/pt.c | 2 +- gcc/testsuite/g++.old-deja/g++.other/crash11.C | 21 ++++++++++++++++ 4 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/crash11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 00038b54ae8..599c7ff254c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +1999-09-18 Mark Mitchell + + * 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 * typeck.c (get_member_function_from_ptrfunc): Always consider diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b1563cf2f94..ed3e11e921d 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 35bf27f9da0..22efc7e1df3 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 00000000000..535a6a2d630 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash11.C @@ -0,0 +1,21 @@ +// Origin: Alfred Minarik +// Build don't link: + +template +struct allocator +{ + typedef int size_type; +}; + +template +struct string +{ + typedef typename allocator::size_type size_type; + + static size_type size; + + size_type + max_size() const { return size; } +}; + +template string ; -- 2.11.4.GIT