]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: module std and exception_ptr
authorJason Merrill <jason@redhat.com>
Wed, 12 Jun 2024 04:13:45 +0000 (00:13 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 12 Jun 2024 20:30:07 +0000 (16:30 -0400)
exception_ptr.h contains

  namespace __exception_ptr
  {
    class exception_ptr;
  }
  using __exception_ptr::exception_ptr;

so when module std tries to 'export using std::exception_ptr', it names
another using-directive rather than the class directly, so __exception_ptr
is never explicitly opened in module purview.

gcc/cp/ChangeLog:

* module.cc (depset::hash::add_binding_entity): Set
DECL_MODULE_PURVIEW_P instead of asserting.

gcc/testsuite/ChangeLog:

* g++.dg/modules/using-20_a.C: New test.

gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/using-20_a.C [new file with mode: 0644]

index 21fc85150c9e08117ca13ad22a73f5fbac5390b8..72e876cec187abc568dc155b8ce5dfb9fef127f1 100644 (file)
@@ -13253,8 +13253,11 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_)
       data->met_namespace = true;
       if (data->hash->add_namespace_entities (decl, data->partitions))
        {
-         /* It contains an exported thing, so it is exported.  */
-         gcc_checking_assert (DECL_MODULE_PURVIEW_P (decl));
+         /* It contains an exported thing, so it is exported.
+            We used to assert DECL_MODULE_PURVIEW_P, but that fails for a
+            namespace like std::__exception_ptr which is never opened in
+            module purview; the exporting using finds another using.  */
+         DECL_MODULE_PURVIEW_P (decl) = true;
          DECL_MODULE_EXPORT_P (decl) = true;
        }
 
diff --git a/gcc/testsuite/g++.dg/modules/using-20_a.C b/gcc/testsuite/g++.dg/modules/using-20_a.C
new file mode 100644 (file)
index 0000000..bb3bb61
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-additional-options "-fmodules-ts -fdump-lang-module -Wno-global-module" }
+// { dg-final { scan-lang-dump {Writing definition '::foo::bar::baz'} module } }
+
+module;
+namespace foo {
+  namespace bar {
+    struct baz { };
+  }
+  using bar::baz;
+}
+export module foo;
+namespace foo {
+  export using foo::baz;
+}