On Fri, 26 Mar 2021, Nathan Sidwell wrote:
>
> During development of modules, I had difficulty deciding whether the
> module
> flags of a template should live on the decl_template_result, the
> template_decl, or both. I chose the latter, and require them to be
> consistent. This and a few other defects show how hard that consistency is.
> Hence this patch move to holding the flags on the template-decl-result decl.
> That's the entity various bits of the parser have at the appropriate time.
> Once needs STRIP_TEMPLATE in a bunch of places, which this patch adds. Also a
> check that we never give a TEMPLATE_DECL to the module flag accessors.
>
> This left a problem with how I was handling template aliases. These were in
> two parts -- separating the TEMPLATE_DECL from the TYPE_DECL. That seemed
> somewhat funky, but development showed it necessary. Of course, that causes
> problems if the TEMPLATE_DECL cannot contain 'am imported' information.
> Investigating now shows that we do not need to treat them separately.
> By
> reverting a bit of template instantiation machinery that caused the problem,
> we're back on course. I think what has happened is that between then and now,
> other typedef fixes have corrected the underlying problem this separation was
> working around. It allows a bunch of cleanup in the decl streamer, as we no
> longer have to handle a null TEMPLATE_DECL_RESULT.
>
>
> PR c++/99283
> gcc/cp/
> * cp-tree.h (DECL_MODULE_CHECK): Ban TEMPLATE_DECL.
This seems to cause us to ICE when calling debug_tree on a
TEMPLATE_DECL. Does the following fix for this look OK?
-- >8 --
Subject: [PATCH] c++: Fix ICE when dumping a TEMPLATE_DECL via debug_tree
This adjusts cxx_print_decl to avoid using the module flag accessors on
a TEMPLATE_DECL after r11-7866 made it an error to do so.
gcc/cp/ChangeLog:
* ptree.c (cxx_print_decl): Don't check module flags on a
TEMPLATE_DECL.
---
gcc/cp/ptree.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c
index 95a4fdf284a..4c4642eccfe 100644
--- a/gcc/cp/ptree.c
+++ b/gcc/cp/ptree.c
@@ -62,7 +62,6 @@ cxx_print_decl (FILE *file, tree node, int indent)
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)
{
--
2.31.1.133.g84d06cdc06