On Tue, Dec 03, 2024 at 05:14:31PM -0500, Jason Merrill wrote:
> GTY((cache)) sounds right to me.  OK with that change.

In that case I think it needs to be simple_cache_map_traits rather
than simple_hashmap_traits.

So, I'll test following patch instead momentarily.  Worked on the
testcase from the PR so far.

2024-12-03  Jakub Jelinek  <ja...@redhat.com>

        PR c++/117826
        * cp-tree.h (struct decl_location_traits): New type.
        (erroneous_templates_t): Change using into typedef.
        (erroneous_templates): Add GTY((cache)).
        * error.cc (cp_adjust_diagnostic_info): Use
        hash_map_safe_get_or_insert<true> rather than
        hash_map_safe_get_or_insert<false> for erroneous_templates.

--- gcc/cp/cp-tree.h.jj 2024-11-29 09:28:09.665459069 +0100
+++ gcc/cp/cp-tree.h    2024-12-03 23:23:50.950277845 +0100
@@ -7222,9 +7222,10 @@ extern location_t location_of
 extern void qualified_name_lookup_error                (tree, tree, tree,
                                                 location_t);
 
-using erroneous_templates_t
-  = hash_map<tree, location_t, simple_hashmap_traits<tree_decl_hash, 
location_t>>;
-extern erroneous_templates_t *erroneous_templates;
+struct decl_location_traits
+  : simple_cache_map_traits<tree_decl_hash, location_t> { };
+typedef hash_map<tree, location_t, decl_location_traits> erroneous_templates_t;
+extern GTY((cache)) erroneous_templates_t *erroneous_templates;
 
 extern bool cp_seen_error ();
 #define seen_error() cp_seen_error ()
--- gcc/cp/error.cc.jj  2024-11-29 09:28:09.679458868 +0100
+++ gcc/cp/error.cc     2024-12-02 12:52:55.079856906 +0100
@@ -237,8 +237,8 @@ cp_adjust_diagnostic_info (diagnostic_co
 
        bool existed;
        location_t &error_loc
-         = hash_map_safe_get_or_insert<false> (erroneous_templates,
-                                               tmpl, &existed);
+         = hash_map_safe_get_or_insert<true> (erroneous_templates,
+                                              tmpl, &existed);
        if (!existed)
          /* Remember that this template had a parse-time error so
             that we'll ensure a hard error has been issued upon


        Jakub

Reply via email to