diff options
author | Mark Mitchell <mark@codesourcery.com> | 2000-01-14 05:45:52 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2000-01-14 05:45:52 +0000 |
commit | 1c2278974cfa5e22ffcde5c13f9cce92225bf812 (patch) | |
tree | 0b0194b94c81e1efdd9a0299177a16c4566e7933 /gcc | |
parent | f1ebdfc52aed6f8e1f832bfd056b8be90b2009ed (diff) | |
download | gcc-1c2278974cfa5e22ffcde5c13f9cce92225bf812.zip gcc-1c2278974cfa5e22ffcde5c13f9cce92225bf812.tar.gz gcc-1c2278974cfa5e22ffcde5c13f9cce92225bf812.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/dump.c | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/crash54.C | 29 |
4 files changed, 45 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5407636..d9cb4fe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +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> * call.c: If GATHER_STATISTICS, declare `n_build_method_call'. diff --git a/gcc/cp/dump.c b/gcc/cp/dump.c index 173cbfa..379ad83 100644 --- a/gcc/cp/dump.c +++ b/gcc/cp/dump.c @@ -1,5 +1,5 @@ /* 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> This file is part of GNU CC. @@ -585,6 +585,8 @@ dequeue_and_dump (di) dump_string (di, "global fini"); 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)); } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index eb0ffd1..67670fa 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4465,9 +4465,9 @@ tsubst_friend_function (decl, args) new_friend_result_template_info = NULL_TREE; } - /* Inside pushdecl_namespace_level, we will push into the - current namespace. However, the friend function should - tyically go into the namespace of the template. */ + /* Inside pushdecl_namespace_level, we will push into the + current namespace. However, the friend function should go + into the namespace of the template. */ ns = decl_namespace_context (new_friend); push_nested_namespace (ns); old_decl = pushdecl_namespace_level (new_friend); @@ -9559,7 +9559,7 @@ instantiate_decl (d) && ! DECL_NEEDED_P (d) /* If the function that caused us to be instantiated is needed, we will be needed, too. */ - && (! nested || ! DECL_NEEDED_P (old_fn))) + && (! nested || (old_fn && ! DECL_NEEDED_P (old_fn)))) DECL_DEFER_OUTPUT (d) = 1; /* We're now committed to instantiating this template. Mark it as diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash54.C b/gcc/testsuite/g++.old-deja/g++.pt/crash54.C new file mode 100644 index 0000000..da66d75 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash54.C @@ -0,0 +1,29 @@ +// 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; +} + |