public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2953] c++: import/export NTTP objects
@ 2022-09-29 11:42 Nathan Sidwell
0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2022-09-29 11:42 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a1f7f9541c2b20eb44750b9c15cd831c62d67f21
commit r13-2953-ga1f7f9541c2b20eb44750b9c15cd831c62d67f21
Author: Nathan Sidwell <nathan@acm.org>
Date: Wed Sep 28 09:21:14 2022 -0700
c++: import/export NTTP objects
This adds smarts to the module machinery to handle NTTP object
VAR_DECLs. Like typeinfo objects, these must be ignored in the symbol
table, streamed specially and recreated on stream in.
gcc/cp/
PR c++/100616
* module.cc (enum tree_tag): Add tt_nttp_var.
(trees_out::decl_node): Handle NTTP objects.
(trees_in::tree_node): Handle tt_nttp_var.
(depset::hash::add_binding_entry): Skip NTTP objects.
gcc/testsuite/
PR c++/100616
* g++.dg/modules/100616_a.H: New.
* g++.dg/modules/100616_b.C: New.
* g++.dg/modules/100616_c.C: New.
* g++.dg/modules/100616_d.C: New.
Diff:
---
gcc/cp/module.cc | 35 +++++++++++++++++++++++++++++++++
gcc/testsuite/g++.dg/modules/100616_a.H | 5 +++++
gcc/testsuite/g++.dg/modules/100616_b.C | 7 +++++++
gcc/testsuite/g++.dg/modules/100616_c.C | 7 +++++++
gcc/testsuite/g++.dg/modules/100616_d.C | 10 ++++++++++
5 files changed, 64 insertions(+)
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index d965017940a..cbf3a77de01 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -2737,6 +2737,7 @@ enum tree_tag {
tt_tinfo_var, /* Typeinfo object. */
tt_tinfo_typedef, /* Typeinfo typedef. */
tt_ptrmem_type, /* Pointer to member type. */
+ tt_nttp_var, /* NTTP_OBJECT VAR_DECL. */
tt_parm, /* Function parameter or result. */
tt_enum_value, /* An enum value. */
@@ -8548,6 +8549,21 @@ trees_out::decl_node (tree decl, walk_kind ref)
}
return false;
}
+
+ if (DECL_NTTP_OBJECT_P (decl))
+ {
+ /* A NTTP parm object. */
+ if (streaming_p ())
+ i (tt_nttp_var);
+ tree_node (tparm_object_argument (decl));
+ tree_node (DECL_NAME (decl));
+ int tag = insert (decl);
+ if (streaming_p ())
+ dump (dumper::TREE)
+ && dump ("Wrote nttp object:%d %N", tag, DECL_NAME (decl));
+ return false;
+ }
+
break;
case TYPE_DECL:
@@ -9627,6 +9643,21 @@ trees_in::tree_node (bool is_use)
}
break;
+ case tt_nttp_var:
+ /* An NTTP object. */
+ {
+ tree init = tree_node ();
+ tree name = tree_node ();
+ if (!get_overrun ())
+ {
+ res = get_template_parm_object (init, name);
+ int tag = insert (res);
+ dump (dumper::TREE)
+ && dump ("Created nttp object:%d %N", tag, name);
+ }
+ }
+ break;
+
case tt_enum_value:
/* An enum const value. */
{
@@ -12760,6 +12791,10 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_)
/* Ignore TINFO things. */
return false;
+ if (TREE_CODE (decl) == VAR_DECL && DECL_NTTP_OBJECT_P (decl))
+ /* Ignore NTTP objects. */
+ return false;
+
if (!(flags & WMB_Using) && CP_DECL_CONTEXT (decl) != data->ns)
{
/* A using that lost its wrapper or an unscoped enum
diff --git a/gcc/testsuite/g++.dg/modules/100616_a.H b/gcc/testsuite/g++.dg/modules/100616_a.H
new file mode 100644
index 00000000000..9bc42bcc05b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/100616_a.H
@@ -0,0 +1,5 @@
+// { dg-additional-options {-std=c++20 -fmodule-header} }
+// { dg-module-cmi {} }
+
+template<auto> struct C { };
+struct A { };
diff --git a/gcc/testsuite/g++.dg/modules/100616_b.C b/gcc/testsuite/g++.dg/modules/100616_b.C
new file mode 100644
index 00000000000..416fd524b2c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/100616_b.C
@@ -0,0 +1,7 @@
+// { dg-additional-options {-std=c++20 -fmodules-ts} }
+
+export module pr100616_b;
+// { dg-module-cmi pr100616_b }
+
+import "100616_a.H";
+export C<A{}> c1;
diff --git a/gcc/testsuite/g++.dg/modules/100616_c.C b/gcc/testsuite/g++.dg/modules/100616_c.C
new file mode 100644
index 00000000000..5c79f5eef68
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/100616_c.C
@@ -0,0 +1,7 @@
+// { dg-additional-options {-std=c++20 -fmodules-ts} }
+
+export module pr100616_c;
+// { dg-module-cmi pr100616_c }
+
+import "100616_a.H";
+export C<A{}> c2;
diff --git a/gcc/testsuite/g++.dg/modules/100616_d.C b/gcc/testsuite/g++.dg/modules/100616_d.C
new file mode 100644
index 00000000000..d9515db1140
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/100616_d.C
@@ -0,0 +1,10 @@
+// { dg-additional-options {-std=c++20 -fmodules-ts} }
+
+import "100616_a.H";
+import pr100616_b;
+import pr100616_c;
+
+C<A{}> c0;
+using type = decltype(c0);
+using type = decltype(c1);
+using type = decltype(c2); // bogus error: types of c1 and c2 don't match
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-29 11:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 11:42 [gcc r13-2953] c++: import/export NTTP objects Nathan Sidwell
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).