diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2003-03-27 12:19:13 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2003-03-27 12:19:13 +0000 |
commit | 649fc72d2638dfc1edac57bb5dc9525bdf4911e5 (patch) | |
tree | 3913c3851b9b6eea4f5dc5186d9881c464352bc5 /gcc/cp | |
parent | 0bcaad20fceb2d9d394242467fa853919141f1c9 (diff) | |
download | gcc-649fc72d2638dfc1edac57bb5dc9525bdf4911e5.zip gcc-649fc72d2638dfc1edac57bb5dc9525bdf4911e5.tar.gz gcc-649fc72d2638dfc1edac57bb5dc9525bdf4911e5.tar.bz2 |
re PR c++/10158 (ICE with templates and friends)
cp:
PR c++/10158
* parser.c (cp_parser_function_definition): Set
DECL_INITIALIZED_IN_CLASS for members.
* pt.c (instantiate_decl): Only reduce the template args for
friends that are not defined in class.
testsuite:
PR c++/10158
* g++.dg/template/friend18.C: New test.
From-SVN: r64920
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 20 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 3 | ||||
-rw-r--r-- | gcc/cp/parser.c | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 14 |
4 files changed, 28 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1fe0268..8d835ec 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2003-03-27 Nathan Sidwell <nathan@codesourcery.com> + + PR c++/10158 + * parser.c (cp_parser_function_definition): Set + DECL_INITIALIZED_IN_CLASS for members. + * pt.c (instantiate_decl): Only reduce the template args for + friends that are not defined in class. + 2003-03-25 Jason Merrill <jason@redhat.com> * call.c (print_z_candidate): Change name of first arg to msgid. @@ -6,23 +14,23 @@ 2003-03-24 Nathan Sidwell <nathan@codesourcery.com> PR c++/9898, PR c++/383, DR 322 - * pt.c (maybe_adjust_types_for_deduction) [DEDUCE_CONV]: Look + * pt.c (maybe_adjust_types_for_deduction) <DEDUCE_CONV>: Look through reference types on both PARM and ARG. 2003-03-24 Nathan Sidwell <nathan@codesourcery.com> PR c++/10119 - * error.c (dump_expr) [BASELINK]: Use dump_expr. + * error.c (dump_expr) <BASELINK>: Use dump_expr. * pt.c (maybe_fold_nontype_args): New function. - (tsubst_copy) [SCOPE_REF]: Subst any template_id args. - [TEMPLATE_ID_EXPR]: Break out folding code, call it. - (tsubst_copy_and_build) [TEMPLATE_ID_EXPR]: Call + (tsubst_copy) <SCOPE_REF>: Subst any template_id args. + <TEMPLATE_ID_EXPR>: Break out folding code, call it. + (tsubst_copy_and_build) <TEMPLATE_ID_EXPR>: Call maybe_fold_nontype_args. 2003-03-24 Nathan Sidwell <nathan@codesourcery.com> PR c++/10026 - * decl2.c (arg_assoc_type) [ERROR_MARK]: Don't die. + * decl2.c (arg_assoc_type) <ERROR_MARK>: Don't die. 2003-03-23 Mark Mitchell <mark@codesourcery.com> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 1c871e8..82fc020 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1987,7 +1987,8 @@ struct lang_decl GTY(()) (TREE_LANG_FLAG_1 (VAR_DECL_CHECK (NODE))) /* Nonzero if the DECL was initialized in the class definition itself, - rather than outside the class. */ + rather than outside the class. This is used for both static member + VAR_DECLS, and FUNTION_DECLS that are defined in the class. */ #define DECL_INITIALIZED_IN_CLASS_P(DECL) \ (DECL_LANG_SPECIFIC (DECL)->decl_flags.initialized_in_class) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 9c157c2..8cc46f9 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -11046,6 +11046,10 @@ cp_parser_function_definition (cp_parser* parser, bool* friend_p) DECL_PENDING_INLINE_INFO (fn) = cache; DECL_PENDING_INLINE_P (fn) = 1; + /* We need to know that this was defined in the class, so that + friend templates are handled correctly. */ + DECL_INITIALIZED_IN_CLASS_P (fn) = 1; + /* We're done with the inline definition. */ finish_method (fn); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ab52970..c04c602 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10804,12 +10804,14 @@ instantiate_decl (d, defer_ok) td = template_for_substitution (d); code_pattern = DECL_TEMPLATE_RESULT (td); - /* In the case of a friend template whose definition is provided - outside the class, we may have too many arguments. Drop the ones - we don't need. */ - args = get_innermost_template_args (gen_args, - TMPL_PARMS_DEPTH - (DECL_TEMPLATE_PARMS (td))); + if (DECL_NAMESPACE_SCOPE_P (d) && !DECL_INITIALIZED_IN_CLASS_P (d)) + /* In the case of a friend template whose definition is provided + outside the class, we may have too many arguments. Drop the + ones we don't need. */ + args = get_innermost_template_args + (gen_args, TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (td))); + else + args = gen_args; if (TREE_CODE (d) == FUNCTION_DECL) pattern_defined = (DECL_SAVED_TREE (code_pattern) != NULL_TREE); |