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
This commit is contained in:
Mark Mitchell 1999-09-18 23:56:18 +00:00 committed by Mark Mitchell
parent b534921ac0
commit 57b524174e
4 changed files with 44 additions and 18 deletions

View 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> 1999-09-18 Martin von Loewis <loewis@informatik.hu-berlin.de>
* typeck.c (get_member_function_from_ptrfunc): Always consider * typeck.c (get_member_function_from_ptrfunc): Always consider

View file

@ -166,7 +166,7 @@ static tree make_label_decl PROTO((tree, int));
static void pop_label PROTO((tree)); static void pop_label PROTO((tree));
static void pop_labels PROTO((tree)); static void pop_labels PROTO((tree));
static void maybe_deduce_size_from_array_init PROTO((tree, 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 void maybe_commonize_var PROTO((tree));
static tree check_initializer PROTO((tree, tree)); static tree check_initializer PROTO((tree, tree));
static void make_rtl_for_nonlocal_decl PROTO((tree, tree, const char *)); 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 /* Set DECL_SIZE, DECL_ALIGN, etc. for DECL (a VAR_DECL), and issue
any appropriate error messages regarding the layout. INIT is a any appropriate error messages regarding the layout. */
the initializer for DECL; returns a modified version. */
static tree static void
layout_var_decl (decl, init) layout_var_decl (decl)
tree decl; tree decl;
tree init;
{ {
tree ttype = target_type (TREE_TYPE (decl)); tree type = TREE_TYPE (decl);
tree ttype = target_type (type);
/* If we haven't already layed out this declaration, and we know its /* If we haven't already layed out this declaration, do so now.
type, do so now. Note that we must not call complete type for an Note that we must not call complete type for an external object
external object because it's type might involve templates that we because it's type might involve templates that we are not
are not supposed to isntantiate yet. */ supposed to isntantiate yet. (And it's perfectly legal to say
if (!DECL_EXTERNAL (decl) `extern X x' for some incomplete type `X'.) */
&& DECL_SIZE (decl) == NULL_TREE if (!DECL_EXTERNAL (decl))
&& TYPE_SIZE (complete_type (TREE_TYPE (decl))) != NULL_TREE) complete_type (type);
if (!DECL_SIZE (decl)&& TYPE_SIZE (type))
layout_decl (decl, 0); layout_decl (decl, 0);
if (!DECL_EXTERNAL (decl) && DECL_SIZE (decl) == NULL_TREE) if (!DECL_EXTERNAL (decl) && DECL_SIZE (decl) == NULL_TREE)
@ -7131,8 +7131,6 @@ layout_var_decl (decl, init)
else else
cp_error ("storage size of `%D' isn't constant", decl); 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 /* 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 (); end_temporary_allocation ();
if (TREE_CODE (decl) == VAR_DECL) 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, /* Output the assembler code and/or RTL code for variables and functions,
unless the type is an undefined structure or union. unless the type is an undefined structure or union.

View file

@ -7446,7 +7446,7 @@ tsubst_expr (t, args, complain, in_decl)
prep_stmt (t); prep_stmt (t);
if (CLEANUP_P (t)) if (CLEANUP_P (t))
{ {
begin_try_block (); stmt = begin_try_block ();
tsubst_expr (TRY_STMTS (t), args, complain, in_decl); tsubst_expr (TRY_STMTS (t), args, complain, in_decl);
finish_cleanup_try_block (stmt); finish_cleanup_try_block (stmt);
finish_cleanup (tsubst_expr (TRY_HANDLERS (t), args, finish_cleanup (tsubst_expr (TRY_HANDLERS (t), args,

View file

@ -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>;