c++, v2: Fix up erroneous template error recovery ICE [PR117826]
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Test passed
|
Commit Message
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 <jakub@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.
Jakub
@@ -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 ()
@@ -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