[PATCH]: Fix PR c++/88095, class template argument deduction for literal operator templates per P0732 for C++2a

Tom Honermann tom@honermann.net
Fri Aug 2 13:59:00 GMT 2019


This patch fixes PR c++/88095:
- Bug 88095 - class nontype template parameter UDL string literals 
doesn't accepts deduction placeholder
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88095.

It also addresses a latent issue; literal operator templates with 
template parameter packs of literal class type were previously accepted. 
  The patch corrects this and adds a test (udlit-class-nttp-neg.C).

In the change to gcc/cp/parser.c, it is not clear to me whether the 
'TREE_CODE (TREE_TYPE (parm)) == TEMPLATE_TYPE_PARM' comparison is 
necessary; it might be that 'CLASS_PLACEHOLDER_TEMPLATE' suffices on its 
own.

If accepted, I'd like to request this change be applied to gcc 9 as it 
is needed for one of the char8_t remediation approaches documented in 
P1423, and may be helpful for existing code bases impacted by the 
char8_t changes adopted via P0482 for C++20.
- https://wg21.link/p1423#emulate

Tested on x86_64-linux.

Thanks to Jeff Snyder for providing an initial patch in the 88059 PR.

gcc/cp/ChangeLog:

2019-08-02  Tom Honermann  <tom@honermann.net>

         * parser.c (cp_parser_template_declaration_after_parameters): 
Enable
         class template argument deduction for non-type template 
parameters in
         literal operator templates.

gcc/testsuite/ChangeLog:

2019-08-02  Tom Honermann  <tom@honermann.net>

         PR c++/88095
         * g++.dg/cpp2a/udlit-class-nttp-ctad.C: New test.
         * g++.dg/cpp2a/udlit-class-nttp-ctad-neg.C: New test.
         * g++.dg/cpp2a/udlit-class-nttp-ctad-neg2.C: New test.
         * g++.dg/cpp2a/udlit-class-nttp.C: New test.
         * g++.dg/cpp2a/udlit-class-nttp-neg.C: New test.
         * g++.dg/cpp2a/udlit-class-nttp-neg2.C: New test.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr88095.patch
Type: text/x-patch
Size: 7219 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190802/0b5bc0ef/attachment.bin>


More information about the Gcc-patches mailing list