]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Only emit exported GMF usings [PR114600]
authorNathaniel Shead <nathanieloshead@gmail.com>
Mon, 8 Apr 2024 13:34:42 +0000 (23:34 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Mon, 15 Apr 2024 08:22:56 +0000 (18:22 +1000)
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
gcc/testsuite/g++.dg/modules/using-14.C [new file with mode: 0644]

index 001430a4a8fe10c513f9eb703486a2b22b11a3b4..d94d8ff4df999969e8ff339da5fbd7e8a9568248 100644 (file)
@@ -13090,7 +13090,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 (file)
index 0000000..0e15a95
--- /dev/null
@@ -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 } }