diff options
author | Jason Merrill <jason@redhat.com> | 2021-04-02 05:45:02 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2021-04-05 08:25:26 -0400 |
commit | a44a753a35542f86e82e198595ce3553f6d718f6 (patch) | |
tree | f51f1d34591c29e5b8119d594c2566ee786d2bf3 /gcc/cp/ptree.c | |
parent | 76a7e7e706ac4c01cead3c6514322aaad88f9a63 (diff) | |
download | gcc-a44a753a35542f86e82e198595ce3553f6d718f6.zip gcc-a44a753a35542f86e82e198595ce3553f6d718f6.tar.gz gcc-a44a753a35542f86e82e198595ce3553f6d718f6.tar.bz2 |
c++: Fix print-tree for TEMPLATE_DECL
The if allows TEMPLATE_DECL, but then checking DECL_MODULE_IMPORT_P crashes
on TEMPLATE_DECL. Fixed by stripping TEMPLATE_DECL first.
gcc/cp/ChangeLog:
* ptree.c (cxx_print_decl): Check DECL_MODULE_IMPORT_P on
template result.
Diffstat (limited to 'gcc/cp/ptree.c')
-rw-r--r-- | gcc/cp/ptree.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c index 95a4fdf..33b73fb 100644 --- a/gcc/cp/ptree.c +++ b/gcc/cp/ptree.c @@ -59,16 +59,16 @@ 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) + tree ntnode = STRIP_TEMPLATE (node); + if (TREE_CODE (ntnode) == FUNCTION_DECL + || TREE_CODE (ntnode) == VAR_DECL + || TREE_CODE (ntnode) == TYPE_DECL + || TREE_CODE (ntnode) == CONCEPT_DECL + || TREE_CODE (ntnode) == NAMESPACE_DECL) { unsigned m = 0; - if (DECL_LANG_SPECIFIC (node) && DECL_MODULE_IMPORT_P (node)) - m = get_importing_module (node, true); + if (DECL_LANG_SPECIFIC (ntnode) && DECL_MODULE_IMPORT_P (ntnode)) + m = get_importing_module (ntnode, true); if (const char *name = m == ~0u ? "" : module_name (m, true)) { @@ -78,7 +78,7 @@ cxx_print_decl (FILE *file, tree node, int indent) need_indent = false; } - if (DECL_LANG_SPECIFIC (node) && DECL_MODULE_PURVIEW_P (node)) + if (DECL_LANG_SPECIFIC (ntnode) && DECL_MODULE_PURVIEW_P (ntnode)) { if (need_indent) indent_to (file, indent + 3); |