Commit 1c227897 by Mark Mitchell Committed by Mark Mitchell

pt.c (tsubst_friend_function): Improve comment.

	* pt.c (tsubst_friend_function): Improve comment.
	(instantiate_decl): Avoid crashing when a "nested" function is
	instantiated from the top level.

From-SVN: r31403
parent f1ebdfc5
2000-01-13 Mark Mitchell <mark@codesourcery.com>
* pt.c (tsubst_friend_function): Improve comment.
(instantiate_decl): Avoid crashing when a "nested" function is
instantiated from the top level.
* dump.c (dqeueue_and_dump): Dump
DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION.
2000-01-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2000-01-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* call.c: If GATHER_STATISTICS, declare `n_build_method_call'. * call.c: If GATHER_STATISTICS, declare `n_build_method_call'.
......
/* Tree-dumping functionality for intermediate representation. /* Tree-dumping functionality for intermediate representation.
Copyright (C) 1999 Free Software Foundation, Inc. Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com> Written by Mark Mitchell <mark@codesourcery.com>
This file is part of GNU CC. This file is part of GNU CC.
...@@ -585,6 +585,8 @@ dequeue_and_dump (di) ...@@ -585,6 +585,8 @@ dequeue_and_dump (di)
dump_string (di, "global fini"); dump_string (di, "global fini");
dump_int (di, "prio", GLOBAL_INIT_PRIORITY (t)); dump_int (di, "prio", GLOBAL_INIT_PRIORITY (t));
} }
if (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t))
dump_string (di, "pseudo tmpl");
dump_child ("body", DECL_SAVED_TREE (t)); dump_child ("body", DECL_SAVED_TREE (t));
} }
......
...@@ -4465,9 +4465,9 @@ tsubst_friend_function (decl, args) ...@@ -4465,9 +4465,9 @@ tsubst_friend_function (decl, args)
new_friend_result_template_info = NULL_TREE; new_friend_result_template_info = NULL_TREE;
} }
/* Inside pushdecl_namespace_level, we will push into the /* Inside pushdecl_namespace_level, we will push into the
current namespace. However, the friend function should current namespace. However, the friend function should go
tyically go into the namespace of the template. */ into the namespace of the template. */
ns = decl_namespace_context (new_friend); ns = decl_namespace_context (new_friend);
push_nested_namespace (ns); push_nested_namespace (ns);
old_decl = pushdecl_namespace_level (new_friend); old_decl = pushdecl_namespace_level (new_friend);
...@@ -9559,7 +9559,7 @@ instantiate_decl (d) ...@@ -9559,7 +9559,7 @@ instantiate_decl (d)
&& ! DECL_NEEDED_P (d) && ! DECL_NEEDED_P (d)
/* If the function that caused us to be instantiated is needed, we /* If the function that caused us to be instantiated is needed, we
will be needed, too. */ will be needed, too. */
&& (! nested || ! DECL_NEEDED_P (old_fn))) && (! nested || (old_fn && ! DECL_NEEDED_P (old_fn))))
DECL_DEFER_OUTPUT (d) = 1; DECL_DEFER_OUTPUT (d) = 1;
/* We're now committed to instantiating this template. Mark it as /* We're now committed to instantiating this template. Mark it as
......
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
template <class T>
int g (T);
int j = g (3);
template <class T>
inline T f (T)
{
return 2;
}
template <class T>
struct S
{
static const int i;
};
template <class T>
const int S<T>::i = f (3);
template <class T>
int g (T)
{
return S<double>::i;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment