void *data)
{
// FIXME: We don't quite deal with using decls naming stat hack
- // type. Also using decls exporting something from the same scope.
+ // type.
tree current = binding;
unsigned count = 0;
}
else if (insert_p)
{
- value = lookup.value;
- if (revealing_p && module_exporting_p ())
- check_can_export_using_decl (value);
+ if (revealing_p
+ && module_exporting_p ()
+ && check_can_export_using_decl (lookup.value)
+ && lookup.value == value
+ && !DECL_MODULE_EXPORT_P (value))
+ {
+ /* We're redeclaring the same value, but this time as
+ newly exported: make sure to mark it as such. */
+ if (TREE_CODE (value) == TEMPLATE_DECL)
+ {
+ DECL_MODULE_EXPORT_P (value) = true;
+
+ tree result = DECL_TEMPLATE_RESULT (value);
+ retrofit_lang_decl (result);
+ DECL_MODULE_PURVIEW_P (result) = true;
+ DECL_MODULE_EXPORT_P (result) = true;
+ }
+ else
+ {
+ retrofit_lang_decl (value);
+ DECL_MODULE_PURVIEW_P (value) = true;
+ DECL_MODULE_EXPORT_P (value) = true;
+ }
+ }
+ else
+ value = lookup.value;
}
/* Now the type binding. */
- if (lookup.type && lookup.type != type)
+ if (lookup.type)
{
if (type && !decls_match (lookup.type, type))
{
}
else if (insert_p)
{
- type = lookup.type;
- if (revealing_p && module_exporting_p ())
- check_can_export_using_decl (type);
+ if (revealing_p
+ && module_exporting_p ()
+ && check_can_export_using_decl (lookup.type)
+ && lookup.type == type
+ && !DECL_MODULE_EXPORT_P (type))
+ {
+ /* We're redeclaring the same type, but this time as
+ newly exported: make sure to mark it as such. */
+ retrofit_lang_decl (type);
+ DECL_MODULE_PURVIEW_P (type) = true;
+ DECL_MODULE_EXPORT_P (type) = true;
+ }
+ else
+ type = lookup.type;
}
}
--- /dev/null
+// { dg-additional-options "-fmodules-ts" }
+// { dg-module-cmi !bad }
+
+// Like using-10.C, but test exporting names within the same namespace.
+
+export module bad;
+
+// internal linkage
+namespace s {
+ namespace {
+ struct a1 {}; // { dg-message "declared here with internal linkage" }
+
+ template <typename T>
+ struct b1; // { dg-message "declared here with internal linkage" }
+
+ int x1; // { dg-message "declared here with internal linkage" }
+
+ template <typename T>
+ T y1; // { dg-message "declared here with internal linkage" }
+
+ void f1(); // { dg-message "declared here with internal linkage" }
+
+ template <typename T>
+ void g1(); // { dg-message "declared here with internal linkage" }
+
+ export using s::a1; // { dg-error "does not have external linkage" }
+ export using s::b1; // { dg-error "does not have external linkage" }
+ export using s::x1; // { dg-error "does not have external linkage" }
+ export using s::y1; // { dg-error "does not have external linkage" }
+ export using s::f1; // { dg-error "does not have external linkage" }
+ export using s::g1; // { dg-error "does not have external linkage" }
+ }
+}
+
+// module linkage
+namespace m {
+ struct a2 {}; // { dg-message "declared here with module linkage" }
+
+ template <typename T>
+ struct b2; // { dg-message "declared here with module linkage" }
+
+ int x2; // { dg-message "declared here with module linkage" }
+
+ template <typename T>
+ T y2; // { dg-message "declared here with module linkage" }
+
+ void f2(); // { dg-message "declared here with module linkage" }
+
+ template <typename T>
+ void g2(); // { dg-message "declared here with module linkage" }
+
+ export using m::a2; // { dg-error "does not have external linkage" }
+ export using m::b2; // { dg-error "does not have external linkage" }
+ export using m::x2; // { dg-error "does not have external linkage" }
+ export using m::y2; // { dg-error "does not have external linkage" }
+ export using m::f2; // { dg-error "does not have external linkage" }
+ export using m::g2; // { dg-error "does not have external linkage" }
+}
+
+namespace t {
+ using a = int; // { dg-message "declared here with no linkage" }
+
+ template <typename T>
+ using b = int; // { dg-message "declared here with no linkage" }
+
+ typedef int c; // { dg-message "declared here with no linkage" }
+
+ export using t::a; // { dg-error "does not have external linkage" }
+ export using t::b; // { dg-error "does not have external linkage" }
+ export using t::c; // { dg-error "does not have external linkage" }
+}
+
+// { dg-prune-output "not writing module" }
--- /dev/null
+// Like using-11.h, but additional kinds of declarations.
+
+struct A {};
+
+template <typename> struct B {};
+template <> struct B<int> { using foo = int; };
+template <typename T> struct B<T*> { using bar = T; };
+
+using C = int;
+
+inline int D = 0;
+
+#if __cpp_concepts >= 201907L
+template <typename>
+concept E = true;
+#endif
--- /dev/null
+// { dg-additional-options "-fmodules-ts" }
+// { dg-module-cmi M }
+
+module;
+#include "using-13.h"
+
+export module M;
+export using ::A;
+export using ::B;
+export using ::C;
+export using ::D;
+
+#if __cpp_concepts >= 201907L
+export using ::E;
+#endif
--- /dev/null
+// { dg-additional-options "-fmodules-ts" }
+
+import M;
+
+int main() {
+ A a;
+
+ // Check all specialisations are correctly exported
+ B<void> b;
+ B<int>::foo b1;
+ B<int*>::bar b2;
+
+ C c;
+
+ auto d = D;
+
+#if __cpp_concepts >= 201907L
+ auto e = E<void>;
+#endif
+}