diff mbox

Fix PR bootstrap/66471

Message ID 5576E606.1060407@suse.cz
State New
Headers show

Commit Message

Martin Liška June 9, 2015, 1:11 p.m. UTC
Hello.

Following patch renames an enum values so that they do not clash with a MinGW reserved keyword.
Patch can bootstrap on MinGW and there's no regression seen on x86_64-linux-unknown-gnu.

Ready for trunk?
Thanks,
Martin

Comments

Richard Biener June 9, 2015, 1:28 p.m. UTC | #1
On Tue, Jun 9, 2015 at 3:11 PM, Martin Liška <mliska@suse.cz> wrote:
> Hello.
>
> Following patch renames an enum values so that they do not clash with a MinGW reserved keyword.

Reserved keyword as in a #define?  Thus simply #undef it in system.h?

> Patch can bootstrap on MinGW and there's no regression seen on x86_64-linux-unknown-gnu.

Does c++04 have scoped enums?  Thus can you use mem_alloc_origin::BITMAP?

Thanks,
Richard.

> Ready for trunk?
> Thanks,
> Martin
İsmail Dönmez June 9, 2015, 1:30 p.m. UTC | #2
Hi,

On Tue, Jun 9, 2015 at 4:28 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Tue, Jun 9, 2015 at 3:11 PM, Martin Liška <mliska@suse.cz> wrote:
>> Hello.
>>
>> Following patch renames an enum values so that they do not clash with a MinGW reserved keyword.
>
> Reserved keyword as in a #define?  Thus simply #undef it in system.h?

No, wingdi.h has the following

  typedef struct tagBITMAP {
    LONG bmType;
    LONG bmWidth;
    LONG bmHeight;
    LONG bmWidthBytes;
    WORD bmPlanes;
    WORD bmBitsPixel;
    LPVOID bmBits;
  } BITMAP,*PBITMAP,*NPBITMAP,*LPBITMAP;
Richard Biener June 9, 2015, 1:35 p.m. UTC | #3
On Tue, Jun 9, 2015 at 3:30 PM, İsmail Dönmez <ismail@donmez.ws> wrote:
> Hi,
>
> On Tue, Jun 9, 2015 at 4:28 PM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Tue, Jun 9, 2015 at 3:11 PM, Martin Liška <mliska@suse.cz> wrote:
>>> Hello.
>>>
>>> Following patch renames an enum values so that they do not clash with a MinGW reserved keyword.
>>
>> Reserved keyword as in a #define?  Thus simply #undef it in system.h?
>
> No, wingdi.h has the following
>
>   typedef struct tagBITMAP {
>     LONG bmType;
>     LONG bmWidth;
>     LONG bmHeight;
>     LONG bmWidthBytes;
>     WORD bmPlanes;
>     WORD bmBitsPixel;
>     LPVOID bmBits;
>   } BITMAP,*PBITMAP,*NPBITMAP,*LPBITMAP;

Hmm. I see.

Patch is ok.

Thanks,
Richard.
diff mbox

Patch

From 740811e0af76af3e1e2f39f149c35bd49ef5fed3 Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Tue, 9 Jun 2015 13:27:53 +0200
Subject: [PATCH] Fix BITMAP identifier clash.

gcc/ChangeLog:

2015-06-09  Martin Liska  <mliska@suse.cz>

	PR bootstrap/66471
	* mem-stats-traits.h (enum mem_alloc_origin): Add _ORIGIN suffix for
	all enum values in mem_alloc_origin.
	* alloc-pool.c (dump_alloc_pool_statistics): Use newly changed enum
	name.
	* alloc-pool.h (pool_allocator::pool_allocator): Likewise.
	* bitmap.c (bitmap_register): Likewise.
	(dump_bitmap_statistics): Likewise.
	* ggc-common.c (dump_ggc_loc_statistics): Likewise.
	(ggc_record_overhead): Likewise.
	* hash-map.h: Likewise.
	* hash-set.h: Likewise.
	* hash-table.c (void dump_hash_table_loc_statistics): Likewise.
	* hash-table.h: Likewise.
	* vec.c (vec_prefix::register_overhead): Likewise.
	(vec_prefix::release_overhead): Likewise.
	(dump_vec_loc_statistics): Likewise.
---
 gcc/alloc-pool.c       |  2 +-
 gcc/alloc-pool.h       |  2 +-
 gcc/bitmap.c           |  5 +++--
 gcc/ggc-common.c       |  4 ++--
 gcc/hash-map.h         |  2 +-
 gcc/hash-set.h         |  2 +-
 gcc/hash-table.c       |  2 +-
 gcc/hash-table.h       |  4 ++--
 gcc/mem-stats-traits.h | 14 +++++++-------
 gcc/vec.c              |  8 +++++---
 10 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c
index bdf184a..7e25915 100644
--- a/gcc/alloc-pool.c
+++ b/gcc/alloc-pool.c
@@ -33,5 +33,5 @@  dump_alloc_pool_statistics (void)
   if (! GATHER_STATISTICS)
     return;
 
-  pool_allocator_usage.dump (ALLOC_POOL);
+  pool_allocator_usage.dump (ALLOC_POOL_ORIGIN);
 }
diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index af3adde..1785df5 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -232,7 +232,7 @@  pool_allocator<T>::pool_allocator (const char *name, size_t num,
   m_elts_free (0), m_blocks_allocated (0), m_block_list (NULL),
   m_block_size (0), m_ignore_type_size (ignore_type_size),
   m_extra_size (extra_size), m_initialized (false),
-  m_location (ALLOC_POOL, false PASS_MEM_STAT) {}
+  m_location (ALLOC_POOL_ORIGIN, false PASS_MEM_STAT) {}
 
 /* Initialize a pool allocator.  */
 
diff --git a/gcc/bitmap.c b/gcc/bitmap.c
index d600ace..733c767 100644
--- a/gcc/bitmap.c
+++ b/gcc/bitmap.c
@@ -30,7 +30,8 @@  mem_alloc_description<bitmap_usage> bitmap_mem_desc;
 void
 bitmap_register (bitmap b MEM_STAT_DECL)
 {
-  bitmap_mem_desc.register_descriptor (b, BITMAP, false FINAL_PASS_MEM_STAT);
+  bitmap_mem_desc.register_descriptor (b, BITMAP_ORIGIN, false
+				       FINAL_PASS_MEM_STAT);
 }
 
 /* Account the overhead.  */
@@ -2076,7 +2077,7 @@  dump_bitmap_statistics (void)
   if (! GATHER_STATISTICS)
     return;
 
-  bitmap_mem_desc.dump (BITMAP);
+  bitmap_mem_desc.dump (BITMAP_ORIGIN);
 }
 
 DEBUG_FUNCTION void
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index 6021c2a..60d427f 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -977,7 +977,7 @@  dump_ggc_loc_statistics (bool final)
   ggc_force_collect = true;
   ggc_collect ();
 
-  ggc_mem_desc.dump (GGC, final ? ggc_usage::compare_final : NULL);
+  ggc_mem_desc.dump (GGC_ORIGIN, final ? ggc_usage::compare_final : NULL);
 
   ggc_force_collect = false;
 }
@@ -986,7 +986,7 @@  dump_ggc_loc_statistics (bool final)
 void
 ggc_record_overhead (size_t allocated, size_t overhead, void *ptr MEM_STAT_DECL)
 {
-  ggc_usage *usage = ggc_mem_desc.register_descriptor (ptr, GGC, false
+  ggc_usage *usage = ggc_mem_desc.register_descriptor (ptr, GGC_ORIGIN, false
 						       FINAL_PASS_MEM_STAT);
 
   ggc_mem_desc.register_object_overhead (usage, allocated + overhead, ptr);
diff --git a/gcc/hash-map.h b/gcc/hash-map.h
index f28f74f..2f1bca4 100644
--- a/gcc/hash-map.h
+++ b/gcc/hash-map.h
@@ -107,7 +107,7 @@  class GTY((user)) hash_map
 public:
   explicit hash_map (size_t n = 13, bool ggc = false,
 		     bool gather_mem_stats = true CXX_MEM_STAT_INFO)
-    : m_table (n, ggc, gather_mem_stats, HASH_MAP PASS_MEM_STAT) {}
+    : m_table (n, ggc, gather_mem_stats, HASH_MAP_ORIGIN PASS_MEM_STAT) {}
 
   /* Create a hash_map in ggc memory.  */
   static hash_map *create_ggc (size_t size, bool gather_mem_stats = true
diff --git a/gcc/hash-set.h b/gcc/hash-set.h
index af91e31..3ec0b15 100644
--- a/gcc/hash-set.h
+++ b/gcc/hash-set.h
@@ -179,7 +179,7 @@  class hash_set
 
 public:
   explicit hash_set (size_t n = 13, bool ggc = false CXX_MEM_STAT_INFO)
-    : m_table (n, ggc, true, HASH_SET PASS_MEM_STAT) {}
+    : m_table (n, ggc, true, HASH_SET_ORIGIN PASS_MEM_STAT) {}
 
   /* Create a hash_set in gc memory with space for at least n elements.  */
 
diff --git a/gcc/hash-table.c b/gcc/hash-table.c
index 012b241..a42b884 100644
--- a/gcc/hash-table.c
+++ b/gcc/hash-table.c
@@ -103,7 +103,7 @@  mem_alloc_description<mem_usage> hash_table_usage;
 /* Support function for statistics.  */
 void dump_hash_table_loc_statistics (void)
 {
-  for (unsigned i = HASH_TABLE; i <= HASH_SET; i++)
+  for (unsigned i = HASH_TABLE_ORIGIN; i <= HASH_SET_ORIGIN; i++)
     {
       mem_alloc_origin origin = (mem_alloc_origin) i;
       hash_table_usage.dump (origin);
diff --git a/gcc/hash-table.h b/gcc/hash-table.h
index 512f162..1b9322d 100644
--- a/gcc/hash-table.h
+++ b/gcc/hash-table.h
@@ -590,7 +590,7 @@  class hash_table
 
 public:
   explicit hash_table (size_t, bool ggc = false, bool gather_mem_stats = true,
-		       mem_alloc_origin origin = HASH_TABLE
+		       mem_alloc_origin origin = HASH_TABLE_ORIGIN
 		       CXX_MEM_STAT_INFO);
   ~hash_table ();
 
@@ -600,7 +600,7 @@  public:
   create_ggc (size_t n CXX_MEM_STAT_INFO)
   {
     hash_table *table = ggc_alloc<hash_table> ();
-    new (table) hash_table (n, true, true, HASH_TABLE PASS_MEM_STAT);
+    new (table) hash_table (n, true, true, HASH_TABLE_ORIGIN PASS_MEM_STAT);
     return table;
   }
 
diff --git a/gcc/mem-stats-traits.h b/gcc/mem-stats-traits.h
index f7843f2..5d27047 100644
--- a/gcc/mem-stats-traits.h
+++ b/gcc/mem-stats-traits.h
@@ -4,13 +4,13 @@ 
 /* Memory allocation origin.  */
 enum mem_alloc_origin
 {
-  HASH_TABLE,
-  HASH_MAP,
-  HASH_SET,
-  VEC,
-  BITMAP,
-  GGC,
-  ALLOC_POOL,
+  HASH_TABLE_ORIGIN,
+  HASH_MAP_ORIGIN,
+  HASH_SET_ORIGIN,
+  VEC_ORIGIN,
+  BITMAP_ORIGIN,
+  GGC_ORIGIN,
+  ALLOC_POOL_ORIGIN,
   MEM_ALLOC_ORIGIN_LENGTH
 };
 
diff --git a/gcc/vec.c b/gcc/vec.c
index e0307dd..b6c3178 100644
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -136,7 +136,8 @@  void
 vec_prefix::register_overhead (void *ptr, size_t size, size_t elements
 			       MEM_STAT_DECL)
 {
-  vec_mem_desc.register_descriptor (ptr, VEC, false FINAL_PASS_MEM_STAT);
+  vec_mem_desc.register_descriptor (ptr, VEC_ORIGIN, false
+				    FINAL_PASS_MEM_STAT);
   vec_usage *usage = vec_mem_desc.register_instance_overhead (size, ptr);
   usage->m_items += elements;
   if (usage->m_items_peak < usage->m_items)
@@ -150,7 +151,8 @@  vec_prefix::release_overhead (void *ptr, size_t size, bool in_dtor
 			      MEM_STAT_DECL)
 {
   if (!vec_mem_desc.contains_descriptor_for_instance (ptr))
-    vec_mem_desc.register_descriptor (ptr, VEC, false FINAL_PASS_MEM_STAT);
+    vec_mem_desc.register_descriptor (ptr, VEC_ORIGIN,
+				      false FINAL_PASS_MEM_STAT);
   vec_mem_desc.release_instance_overhead (ptr, size, in_dtor);
 }
 
@@ -185,5 +187,5 @@  vec_prefix::calculate_allocation_1 (unsigned alloc, unsigned desired)
 void
 dump_vec_loc_statistics (void)
 {
-  vec_mem_desc.dump (VEC);
+  vec_mem_desc.dump (VEC_ORIGIN);
 }
-- 
2.1.4