diff mbox series

[ping] Use 'location_hash' for 'gcc/diagnostic-spec.h:nowarn_map'

Message ID 87pmr1jweq.fsf@euler.schwinge.homeip.net
State New
Headers show
Series [ping] Use 'location_hash' for 'gcc/diagnostic-spec.h:nowarn_map' | expand

Commit Message

Thomas Schwinge Nov. 15, 2021, 3:01 p.m. UTC
Hi!

Ping.


Grüße
 Thomas


On 2021-11-09T15:18:44+0100, I wrote:
> Hi!
>
> On 2021-09-03T21:16:46+0200, I wrote:
>> On 2021-09-01T18:14:46-0600, Martin Sebor <msebor@gmail.com> wrote:
>>> On 9/1/21 1:35 PM, Thomas Schwinge wrote:
>>>> On 2021-06-23T13:47:08-0600, Martin Sebor via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>>>>> --- /dev/null
>>>>> +++ b/gcc/diagnostic-spec.h
>>>>
>>>>> +typedef location_t key_type_t;
>>>>> +typedef int_hash <key_type_t, 0, UINT_MAX> xint_hash_t;
>>
>>> By the way, it seems we should probably also use a manifest constant
>>> for Empty (probably UNKNOWN_LOCATION since we're reserving it).
>>
>> Yes, that will be part of another patch here -- waiting for approval of
>> "Generalize 'gcc/input.h:struct location_hash'" posted elsewhere.
>
> ... which I have now pushed, so I may now propose the attached patch to
> "Use 'location_hash' for 'gcc/diagnostic-spec.h:nowarn_map'".  OK to
> push?
>
>
> Grüße
>  Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

Comments

Martin Sebor Nov. 15, 2021, 4:43 p.m. UTC | #1
On 11/15/21 8:01 AM, Thomas Schwinge wrote:
> Hi!
> 
> Ping.

This change looks good to me.

Martin

> 
> Grüße
>   Thomas
> 
> 
> On 2021-11-09T15:18:44+0100, I wrote:
>> Hi!
>>
>> On 2021-09-03T21:16:46+0200, I wrote:
>>> On 2021-09-01T18:14:46-0600, Martin Sebor <msebor@gmail.com> wrote:
>>>> On 9/1/21 1:35 PM, Thomas Schwinge wrote:
>>>>> On 2021-06-23T13:47:08-0600, Martin Sebor via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>>>>>> --- /dev/null
>>>>>> +++ b/gcc/diagnostic-spec.h
>>>>>
>>>>>> +typedef location_t key_type_t;
>>>>>> +typedef int_hash <key_type_t, 0, UINT_MAX> xint_hash_t;
>>>
>>>> By the way, it seems we should probably also use a manifest constant
>>>> for Empty (probably UNKNOWN_LOCATION since we're reserving it).
>>>
>>> Yes, that will be part of another patch here -- waiting for approval of
>>> "Generalize 'gcc/input.h:struct location_hash'" posted elsewhere.
>>
>> ... which I have now pushed, so I may now propose the attached patch to
>> "Use 'location_hash' for 'gcc/diagnostic-spec.h:nowarn_map'".  OK to
>> push?
>>
>>
>> Grüße
>>   Thomas
> 
> 
> -----------------
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
>
diff mbox series

Patch

From d346292fc95f1990abbc9f6a4a8eb89be0f0e88d Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 31 Aug 2021 23:35:15 +0200
Subject: [PATCH] Use 'location_hash' for 'gcc/diagnostic-spec.h:nowarn_map'

Instead of hard-coded '0'/'UINT_MAX', we now use the 'RESERVED_LOCATION_P'
values 'UNKNOWN_LOCATION'/'BUILTINS_LOCATION' as spare values for
'Empty'/'Deleted', and generally simplify the code.

	gcc/
	* diagnostic-spec.h (typedef xint_hash_t)
	(typedef xint_hash_map_t): Replace with...
	(typedef nowarn_map_t): ... this.
	(nowarn_map): Adjust.
	* diagnostic-spec.c (nowarn_map, suppress_warning_at): Likewise.
---
 gcc/diagnostic-spec.c | 4 ++--
 gcc/diagnostic-spec.h | 9 ++-------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/gcc/diagnostic-spec.c b/gcc/diagnostic-spec.c
index 85ffb725c02..d1e563d19ba 100644
--- a/gcc/diagnostic-spec.c
+++ b/gcc/diagnostic-spec.c
@@ -107,7 +107,7 @@  nowarn_spec_t::nowarn_spec_t (opt_code opt)
 
 /* A mapping from a 'location_t' to the warning spec set for it.  */
 
-GTY(()) xint_hash_map_t *nowarn_map;
+GTY(()) nowarn_map_t *nowarn_map;
 
 /* Return the no-warning disposition for location LOC and option OPT
    or for all/any otions by default.  */
@@ -163,7 +163,7 @@  suppress_warning_at (location_t loc, opt_code opt /* = all_warnings */,
     return false;
 
   if (!nowarn_map)
-    nowarn_map = xint_hash_map_t::create_ggc (32);
+    nowarn_map = nowarn_map_t::create_ggc (32);
 
   nowarn_map->put (loc, optspec);
   return true;
diff --git a/gcc/diagnostic-spec.h b/gcc/diagnostic-spec.h
index e54e9e3ddbe..368b75f3254 100644
--- a/gcc/diagnostic-spec.h
+++ b/gcc/diagnostic-spec.h
@@ -130,14 +130,9 @@  operator!= (const nowarn_spec_t &lhs, const nowarn_spec_t &rhs)
   return !(lhs == rhs);
 }
 
-/* Per PR103157 "'gengtype': 'typedef' causing infinite-recursion code to be
-   generated", don't use
-       typedef int_hash<location_t, 0, UINT_MAX> xint_hash_t;
-   here.  */
-struct xint_hash_t : int_hash<location_t, 0, UINT_MAX> {};
-typedef hash_map<xint_hash_t, nowarn_spec_t> xint_hash_map_t;
+typedef hash_map<location_hash, nowarn_spec_t> nowarn_map_t;
 
 /* A mapping from a 'location_t' to the warning spec set for it.  */
-extern GTY(()) xint_hash_map_t *nowarn_map;
+extern GTY(()) nowarn_map_t *nowarn_map;
 
 #endif // DIAGNOSTIC_SPEC_H_INCLUDED
-- 
2.33.0