This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH for Re: egcs-1.0.2, egcs-980315 and templates
- To: mmitchell at usa dot net
- Subject: Re: PATCH for Re: egcs-1.0.2, egcs-980315 and templates
- From: Andrew Pollard <andrew at odie dot demon dot co dot uk>
- Date: Mon, 23 Mar 1998 16:07:46 GMT
- CC: egcs at cygnus dot com
Mark Mitchell <mmitchell@usa.net> wrote:
>Andrew --
>
> Here's a patch for your problem. Jason?
>
Just to let you know that this worked fine for me (under egcs-980321).
>>From what I could understand from the draft C++ spec, I can't see why
>>the call to foo(k) in A::bar should instantiate the template and hence
>>make the specialization invalid.
Glad to see that I did understand the C++ spec correctly :-)
Cheers,
Andrew.
>
>Sat Mar 21 19:00:03 1998 Mark Mitchell <mmitchell@usa.net>
>
> * pt.c (tsubst): Clear TREE_USED for new FUNCTION_DECLs.
>
>Index: pt.c
>===================================================================
>RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
>retrieving revision 1.101
>diff -c -p -r1.101 pt.c
>*** pt.c 1998/03/20 10:44:05 1.101
>--- pt.c 1998/03/22 02:57:30
>*************** tsubst (t, args, in_decl)
>*** 4063,4068 ****
>--- 4197,4203 ----
> TREE_CHAIN (r) = NULL_TREE;
> DECL_CHAIN (r) = NULL_TREE;
> DECL_PENDING_INLINE_INFO (r) = 0;
>+ TREE_USED (r) = 0;
>
> if (IDENTIFIER_OPNAME_P (DECL_NAME (r)))
> grok_op_properties (r, DECL_VIRTUAL_P (r), DECL_FRIEND_P (r));
>Index: spec16.C
>===================================================================
>RCS file: spec16.C
>diff -N spec16.C
>*** /dev/null Mon Dec 31 20:00:00 1979
>--- spec16.C Sat Mar 21 19:00:01 1998
>***************
>*** 0 ****
>--- 1,21 ----
>+ // Build don't link:
>+
>+ template<class K>
>+ struct A {
>+ int foo(const K&);
>+ int bar(const K&);
>+ };
>+
>+ template<class K>
>+ int
>+ A<K>::bar(const K& k)
>+ {
>+ return(foo(k));
>+ }
>+
>+ template<>
>+ int
>+ A<const char*>::foo(const char*const& k)
>+ {
>+ return((int)k);
>+ }