public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3362] c++ modules: stream non-trailing default targs [PR105045]
@ 2022-10-18 14:58 Patrick Palka
0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2022-10-18 14:58 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0101137c7c5d612c0624f9a2fd5198b302243f85
commit r13-3362-g0101137c7c5d612c0624f9a2fd5198b302243f85
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Oct 18 10:57:30 2022 -0400
c++ modules: stream non-trailing default targs [PR105045]
This fixes the below testcase in which we neglect to stream the default
argument for T only because the subsequent parameter U doesn't also have
a default argument.
PR c++/105045
gcc/cp/ChangeLog:
* module.cc (trees_out::tpl_parms_fini): Don't assume default
template arguments must be trailing.
(trees_in::tpl_parms_fini): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/modules/pr105045_a.C: New test.
* g++.dg/modules/pr105045_b.C: New test.
Diff:
---
gcc/cp/module.cc | 20 ++++++--------------
gcc/testsuite/g++.dg/modules/pr105045_a.C | 7 +++++++
gcc/testsuite/g++.dg/modules/pr105045_b.C | 6 ++++++
3 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 999ff3faafc..2c2f9a9a8cb 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -10034,15 +10034,11 @@ trees_out::tpl_parms_fini (tree tmpl, unsigned tpl_levels)
tree vec = TREE_VALUE (parms);
tree_node (TREE_TYPE (vec));
- tree dflt = error_mark_node;
for (unsigned ix = TREE_VEC_LENGTH (vec); ix--;)
{
tree parm = TREE_VEC_ELT (vec, ix);
- if (dflt)
- {
- dflt = TREE_PURPOSE (parm);
- tree_node (dflt);
- }
+ tree dflt = TREE_PURPOSE (parm);
+ tree_node (dflt);
if (streaming_p ())
{
@@ -10072,19 +10068,15 @@ trees_in::tpl_parms_fini (tree tmpl, unsigned tpl_levels)
tpl_levels--; parms = TREE_CHAIN (parms))
{
tree vec = TREE_VALUE (parms);
- tree dflt = error_mark_node;
TREE_TYPE (vec) = tree_node ();
for (unsigned ix = TREE_VEC_LENGTH (vec); ix--;)
{
tree parm = TREE_VEC_ELT (vec, ix);
- if (dflt)
- {
- dflt = tree_node ();
- if (get_overrun ())
- return false;
- TREE_PURPOSE (parm) = dflt;
- }
+ tree dflt = tree_node ();
+ if (get_overrun ())
+ return false;
+ TREE_PURPOSE (parm) = dflt;
tree decl = TREE_VALUE (parm);
if (TREE_CODE (decl) == TEMPLATE_DECL)
diff --git a/gcc/testsuite/g++.dg/modules/pr105045_a.C b/gcc/testsuite/g++.dg/modules/pr105045_a.C
new file mode 100644
index 00000000000..597f9294185
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr105045_a.C
@@ -0,0 +1,7 @@
+// PR c++/105045
+// { dg-additional-options -fmodules-ts }
+// { dg-module-cmi pr105045 }
+
+export module pr105045;
+
+export template<int T=0, class U> void f(U) { }
diff --git a/gcc/testsuite/g++.dg/modules/pr105045_b.C b/gcc/testsuite/g++.dg/modules/pr105045_b.C
new file mode 100644
index 00000000000..77c94d4c473
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/pr105045_b.C
@@ -0,0 +1,6 @@
+// PR c++/105045
+// { dg-additional-options -fmodules-ts }
+
+import pr105045;
+
+int main() { f(0); }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-18 14:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18 14:58 [gcc r13-3362] c++ modules: stream non-trailing default targs [PR105045] Patrick Palka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).