This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [REVISED PATCH][RFC] Fix PR c++/31923: Storage class with explicit template specialization
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Simon Baldwin <simonb at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 15 Jun 2007 11:49:27 -0700
- Subject: Re: [REVISED PATCH][RFC] Fix PR c++/31923: Storage class with explicit template specialization
- References: <20070615174708.E6C3141A0C0@localhost>
Simon Baldwin wrote:
> gcc/cp/ChangeLog
> 2007-06-15 Simon Baldwin <simonb@google.com>
>
> PR c++/31923
> * parser.c (cp_parser_single_declaration): Added check for storage
> class other than sc_none in parsed declaration, and a flag to indicate
> if the call is part of an explicit template specialization parse.
> * (cp_parser_explicit_specialization): Specialization check flag added
> to call to cp_parser_single_declaration(), set true.
> * (cp_parser_template_declaration_after_export): Specialization check
> flag added to call to cp_parser_single_declaration(), set false.
> * pt.c (check_explicit_specialization): Added code to copy visiblity
> and linkage from the templated function to the explicit specialization.
This looks good. A couple of questions:
> + if (tsk == tsk_expl_spec
> + && TREE_CODE (decl) == FUNCTION_DECL
> + && DECL_TEMPLATE_INFO (decl) && DECL_USE_TEMPLATE (decl)
> + && DECL_FUNCTION_TEMPLATE_P (gen_tmpl))
> + {
> + tree tmpl_func = DECL_TEMPLATE_RESULT (gen_tmpl);
> + gcc_assert (TREE_CODE (tmpl_func) == FUNCTION_DECL);
> +
> + /* This specialization has the same linkage and visiblity as
> + the function template it specializes. */
> + TREE_PUBLIC (decl) = TREE_PUBLIC (tmpl_func);
> + DECL_THIS_STATIC (decl) = DECL_THIS_STATIC (tmpl_func);
> + }
The condition seems complicated. What are you trying to check exactly?
Why isn't just
tsk == tsk_expl_spec && DECL_FUNCTION_TEMPLATE_P (gen_tmpl)
enough?
Also, shouldn't we copy ELF symbol visibility here too?
> + // { dg-final { scan-assembler-not ".glob(a|)l\[\t \]*_Z2f1IiEvT_" } }
> + f1(0); // Expected to have static linkage
> +
> + // { dg-final { scan-assembler ".weak\[\t \]*_Z2f2IiEvT_" } }
> + f2(0); // Expected to have weak global linkage
Do we have a DejaGNU function to check for weakness? If not, we should.
And, we may as well add one to check for external/global-ness too.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713