Commit 649fc72d by Nathan Sidwell Committed by Nathan Sidwell

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
parent 0bcaad20
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>
......
......@@ -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)
......
......@@ -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);
......
......@@ -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);
......
2003-03-27 Nathan Sidwell <nathan@codesourcery.com>
PR c++/10158
* g++.dg/template/friend18.C: New test.
2003-03-26 Roger Sayle <roger@eyesopen.com>
* g77.f-torture/compile/20030326-1.f: New test case.
......
// { dg-do run }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 Mar 2003 <nathan@codesourcery.com>
// PR 10158. implicit inline template friends ICE'd
template <int N> struct X
{
template <int M> friend int foo(X const &)
{
return N * 10000 + M;
}
};
X<1234> bring;
int main() {
return foo<5678> (bring) != 12345678;
}
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