From 8c60696b699e0b22cc12ae628473f0a23f90c82e Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 9 Dec 2020 12:18:06 -0800 Subject: c++: Module-specific error and tree dumping With modules, we need the ability to name 'foos' in different modules. The idiom for that is a trailing '@modulename' suffix. This adds that to the error printing routines. I also augment the tree dumping machinery to show module-specific metadata. gcc/cp/ * error.c (dump_module_suffix): New. (dump_aggr_type, dump_simple_decl, dump_function_name): Call it. * ptree.c (cxx_print_decl): Print module information. * module.cc (module_name, get_importing_module): Stubs. --- gcc/cp/ptree.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'gcc/cp/ptree.c') 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) -- cgit v1.1