]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Fix imported CNTTPs being considered non-constant [PR119938]
authorNathaniel Shead <nathanieloshead@gmail.com>
Fri, 25 Apr 2025 12:45:41 +0000 (22:45 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Wed, 30 Apr 2025 23:51:31 +0000 (09:51 +1000)
commitd613678c94f06809656e56b37f314501b37a5ddd
tree881f6dc710188b83f5e142a0dba88f6f96da9e42
parent22ccaded63e96e5a42f4e3676dbbb57aa05b36f9
c++/modules: Fix imported CNTTPs being considered non-constant [PR119938]

When importing a CNTTP object, since r15-3031-g0b7904e274fbd6 we
shortcut the processing of the generated NTTP so that we don't attempt
to recursively load pendings.  However, due to an oversight we do not
properly set TREE_CONSTANT or DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P
on the decl, which confuses later processing.  This patch ensures that
this happens correctly.

PR c++/119938

gcc/cp/ChangeLog:

* pt.cc (get_template_parm_object): When !check_init, add assert
that expr really is constant and mark decl as such.

gcc/testsuite/ChangeLog:

* g++.dg/modules/tpl-nttp-2_a.H: New test.
* g++.dg/modules/tpl-nttp-2_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/pt.cc
gcc/testsuite/g++.dg/modules/tpl-nttp-2_a.H [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/tpl-nttp-2_b.C [new file with mode: 0644]