aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/error.c39
-rw-r--r--gcc/cp/module.cc11
-rw-r--r--gcc/cp/ptree.c36
3 files changed, 86 insertions, 0 deletions
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index d11591d..4572f6e 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -179,6 +179,38 @@ cxx_initialize_diagnostics (diagnostic_context *context)
pp->m_format_postprocessor = new cxx_format_postprocessor ();
}
+/* Dump an '@module' name suffix for DECL, if any. */
+
+static void
+dump_module_suffix (cxx_pretty_printer *pp, tree decl)
+{
+ if (!modules_p ())
+ return;
+
+ if (!DECL_CONTEXT (decl))
+ return;
+
+ if (TREE_CODE (decl) != CONST_DECL
+ || !UNSCOPED_ENUM_P (DECL_CONTEXT (decl)))
+ {
+ if (!DECL_NAMESPACE_SCOPE_P (decl))
+ return;
+
+ if (TREE_CODE (decl) == NAMESPACE_DECL
+ && !DECL_NAMESPACE_ALIAS (decl)
+ && (TREE_PUBLIC (decl) || !TREE_PUBLIC (CP_DECL_CONTEXT (decl))))
+ return;
+ }
+
+ if (unsigned m = get_originating_module (decl))
+ if (const char *n = module_name (m, false))
+ {
+ pp_character (pp, '@');
+ pp->padding = pp_none;
+ pp_string (pp, n);
+ }
+}
+
/* Dump a scope, if deemed necessary. */
static void
@@ -771,6 +803,8 @@ dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags)
else
pp_cxx_tree_identifier (pp, DECL_NAME (decl));
+ dump_module_suffix (pp, decl);
+
if (tmplate)
dump_template_parms (pp, TYPE_TEMPLATE_INFO (t),
!CLASSTYPE_USE_TEMPLATE (t),
@@ -1077,6 +1111,9 @@ dump_simple_decl (cxx_pretty_printer *pp, tree t, tree type, int flags)
pp_string (pp, M_("<structured bindings>"));
else
pp_string (pp, M_("<anonymous>"));
+
+ dump_module_suffix (pp, t);
+
if (flags & TFF_DECL_SPECIFIERS)
dump_type_suffix (pp, type, flags);
}
@@ -1894,6 +1931,8 @@ dump_function_name (cxx_pretty_printer *pp, tree t, int flags)
else
dump_decl (pp, name, flags);
+ dump_module_suffix (pp, t);
+
if (DECL_TEMPLATE_INFO (t)
&& !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t)
&& (TREE_CODE (DECL_TI_TEMPLATE (t)) != TEMPLATE_DECL
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 3587dfc..176286c 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -74,6 +74,11 @@ get_module (tree, module_state *, bool)
return nullptr;
}
+const char *
+module_name (unsigned, bool)
+{
+ return nullptr;
+}
void
mangle_module (int, bool)
@@ -102,6 +107,12 @@ get_originating_module (tree, bool)
return 0;
}
+unsigned
+get_importing_module (tree, bool)
+{
+ return 0;
+}
+
bool
module_may_redeclare (tree)
{
diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c
index f8d2208..1e9fdf8 100644
--- a/gcc/cp/ptree.c
+++ b/gcc/cp/ptree.c
@@ -59,6 +59,42 @@ cxx_print_decl (FILE *file, tree node, int indent)
bool need_indent = true;
+ if (TREE_CODE (node) == FUNCTION_DECL
+ || TREE_CODE (node) == VAR_DECL
+ || TREE_CODE (node) == TYPE_DECL
+ || TREE_CODE (node) == TEMPLATE_DECL
+ || TREE_CODE (node) == CONCEPT_DECL
+ || TREE_CODE (node) == NAMESPACE_DECL)
+ {
+ unsigned m = 0;
+ if (DECL_LANG_SPECIFIC (node) && DECL_MODULE_IMPORT_P (node))
+ m = get_importing_module (node, true);
+
+ if (const char *name = m == ~0u ? "" : module_name (m, true))
+ {
+ if (need_indent)
+ indent_to (file, indent + 3);
+ fprintf (file, " module %d:%s", m, name);
+ need_indent = false;
+ }
+
+ if (DECL_LANG_SPECIFIC (node) && DECL_MODULE_PURVIEW_P (node))
+ {
+ if (need_indent)
+ indent_to (file, indent + 3);
+ fprintf (file, " purview");
+ need_indent = false;
+ }
+ }
+
+ if (DECL_MODULE_EXPORT_P (node))
+ {
+ if (need_indent)
+ indent_to (file, indent + 3);
+ fprintf (file, " exported");
+ need_indent = false;
+ }
+
if (DECL_EXTERNAL (node) && DECL_NOT_REALLY_EXTERN (node))
{
if (need_indent)