]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: C++20 class NTTP trailing zero-init [PR100079]
authorJason Merrill <jason@redhat.com>
Wed, 14 Apr 2021 21:27:19 +0000 (17:27 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 16 Apr 2021 05:16:03 +0000 (01:16 -0400)
commit89c863488bc8c7315596bcb753173aa2fd8be727
tree23f643de494414e8cbb18cf5d22fc3007daac151
parentee351f7fdbd82f8947fe9a0e74cea65d216a8549
c++: C++20 class NTTP trailing zero-init [PR100079]

The new testcase was breaking because constexpr evaluation was simplifying
Bar{Baz<42>{}} to Bar{empty}, but then we weren't treating them as
equivalent.  Poking at this revealed that the code for eliding trailing
zero-initialization in class non-type template argument mangling was pretty
broken, including the test, mangle71.

I dealt with the FIXME to support RANGE_EXPR, and fixed the confusion
between a list-initialized temporary mangled as written (i.e. in the
signature of a function template) and a template parameter object mangled as
the value representation of the object.  I'm distinguishing between these
using COMPOUND_LITERAL_P.  A later patch will adjust the use of
COMPOUND_LITERAL_P to be more useful for this distinction, but it works now
for distinguishing these cases in mangling.

gcc/cp/ChangeLog:

PR c++/100079
* cp-tree.h (first_field): Declare.
* mangle.c (range_expr_nelts): New.
(write_expression): Improve class NTTP mangling.
* pt.c (get_template_parm_object): Clear TREE_HAS_CONSTRUCTOR.
* tree.c (zero_init_expr_p): Improve class NTTP handling.
* decl.c: Adjust comment.

gcc/testsuite/ChangeLog:

PR c++/100079
* g++.dg/abi/mangle71.C: Fix expected mangling.
* g++.dg/abi/mangle77.C: New test.
* g++.dg/cpp2a/nontype-class-union1.C: Likewise.
* g++.dg/cpp2a/nontype-class-equiv1.C: Removed.
* g++.dg/cpp2a/nontype-class44.C: New test.
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/mangle.c
gcc/cp/pt.c
gcc/cp/tree.c
gcc/testsuite/g++.dg/abi/mangle71.C
gcc/testsuite/g++.dg/abi/mangle77.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/nontype-class-equiv1.C [deleted file]
gcc/testsuite/g++.dg/cpp2a/nontype-class-union1.C
gcc/testsuite/g++.dg/cpp2a/nontype-class44.C [new file with mode: 0644]