Message ID | 661882e6.170a0220.5eebf.5da0@mx.google.com |
---|---|
State | New |
Headers | show |
Series | c++/modules: Fix some small issues with exported using-decls | expand |
On 4/11/24 20:40, Nathaniel Shead wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? OK. > -- >8 -- > > A typo in r14-6978 made us emit too many things. This ensures that we > don't emit using-declarations from the GMF that we don't need to. > > PR c++/114600 > > gcc/cp/ChangeLog: > > * module.cc (depset::hash::add_binding_entity): Require both > WMB_Using and WMB_Export for GMF entities. > > gcc/testsuite/ChangeLog: > > * g++.dg/modules/using-14.C: New test. > > Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> > Co-authored-by: Patrick Palka <ppalka@redhat.com> > --- > gcc/cp/module.cc | 2 +- > gcc/testsuite/g++.dg/modules/using-14.C | 14 ++++++++++++++ > 2 files changed, 15 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/modules/using-14.C > > diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc > index 4e91fa6e052..9d054c4c792 100644 > --- a/gcc/cp/module.cc > +++ b/gcc/cp/module.cc > @@ -12892,7 +12892,7 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) > inner = DECL_TEMPLATE_RESULT (inner); > > if ((!DECL_LANG_SPECIFIC (inner) || !DECL_MODULE_PURVIEW_P (inner)) > - && !(flags & (WMB_Using | WMB_Export))) > + && !((flags & WMB_Using) && (flags & WMB_Export))) > /* Ignore global module fragment entities unless explicitly > exported with a using declaration. */ > return false; > diff --git a/gcc/testsuite/g++.dg/modules/using-14.C b/gcc/testsuite/g++.dg/modules/using-14.C > new file mode 100644 > index 00000000000..0e15a952de5 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/modules/using-14.C > @@ -0,0 +1,14 @@ > +// PR c++/114600 > +// { dg-additional-options "-fmodules-ts -Wno-global-module -fdump-lang-module" } > +// { dg-module-cmi M } > + > +module; > +namespace std { > + template<class T> struct A { int n; }; > + template<class T> A<T> f(); > + namespace __swappable_details { using std::f; } > +} > +export module M; > + > +// The whole GMF should be discarded here > +// { dg-final { scan-lang-dump "Wrote 0 clusters" module } }
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 4e91fa6e052..9d054c4c792 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -12892,7 +12892,7 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) inner = DECL_TEMPLATE_RESULT (inner); if ((!DECL_LANG_SPECIFIC (inner) || !DECL_MODULE_PURVIEW_P (inner)) - && !(flags & (WMB_Using | WMB_Export))) + && !((flags & WMB_Using) && (flags & WMB_Export))) /* Ignore global module fragment entities unless explicitly exported with a using declaration. */ return false; diff --git a/gcc/testsuite/g++.dg/modules/using-14.C b/gcc/testsuite/g++.dg/modules/using-14.C new file mode 100644 index 00000000000..0e15a952de5 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-14.C @@ -0,0 +1,14 @@ +// PR c++/114600 +// { dg-additional-options "-fmodules-ts -Wno-global-module -fdump-lang-module" } +// { dg-module-cmi M } + +module; +namespace std { + template<class T> struct A { int n; }; + template<class T> A<T> f(); + namespace __swappable_details { using std::f; } +} +export module M; + +// The whole GMF should be discarded here +// { dg-final { scan-lang-dump "Wrote 0 clusters" module } }
Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- A typo in r14-6978 made us emit too many things. This ensures that we don't emit using-declarations from the GMF that we don't need to. PR c++/114600 gcc/cp/ChangeLog: * module.cc (depset::hash::add_binding_entity): Require both WMB_Using and WMB_Export for GMF entities. gcc/testsuite/ChangeLog: * g++.dg/modules/using-14.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Co-authored-by: Patrick Palka <ppalka@redhat.com> --- gcc/cp/module.cc | 2 +- gcc/testsuite/g++.dg/modules/using-14.C | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/modules/using-14.C