RFA: Remove use of register keyword in libiberty.h

Message ID 87eeq3zbtx.fsf@redhat.com
State Superseded
Headers show
Series
  • RFA: Remove use of register keyword in libiberty.h
Related show

Commit Message

Jakub Jelinek via Gcc-patches June 25, 2020, 10:20 a.m.
Hi Ian, Hi Nick,

  Comping the GOLD linker with Clang has started producing this error
  message:

    In file included from gold/archive.cc:29:
    include/libiberty.h:646:25: error: 'register' storage class
      specifier is deprecated and incompatible with C++17
      [-Werror,-Wdeprecated-register]

  So I would like to apply the patch below to fix this.  Is this OK ?
  
Cheers
  Nick

include/ChangeLog
2020-06-25  Nick Clifton  <nickc@redhat.com>

	* libiberty.h (bsearch_r): Remove use of the register keyword from
	the prototype.

Comments

Jakub Jelinek via Gcc-patches June 25, 2020, 10:56 a.m. | #1
On 25 Jun 2020, Nick Clifton outgrape:

> Hi Ian, Hi Nick,

>

>   Comping the GOLD linker with Clang has started producing this error

>   message:

>

>     In file included from gold/archive.cc:29:

>     include/libiberty.h:646:25: error: 'register' storage class

>       specifier is deprecated and incompatible with C++17

>       [-Werror,-Wdeprecated-register]

>

>   So I would like to apply the patch below to fix this.  Is this OK ?


Yes please! This was copied straight from bsearch.c, so you probably
want to change bsearch.c and bsearch_r.c as well (just in case clang
ever finds itself needing to build bsearch_r out of libiberty).
Jakub Jelinek via Gcc-patches June 25, 2020, 11:05 a.m. | #2
Hi Nick, Hi Ian, 
>>     In file included from gold/archive.cc:29:

>>     include/libiberty.h:646:25: error: 'register' storage class

>>       specifier is deprecated and incompatible with C++17

>>       [-Werror,-Wdeprecated-register]

>>

>>   So I would like to apply the patch below to fix this.  Is this OK ?

> 

> Yes please! This was copied straight from bsearch.c, so you probably

> want to change bsearch.c and bsearch_r.c as well (just in case clang

> ever finds itself needing to build bsearch_r out of libiberty).


OK, here is a revised patch.  Ian - is this OK ?

Cheers
  Nick

include/ChangeLog
2020-06-25  Nick Clifton  <nickc@redhat.com>

	* libiberty.h (bsearch_r): Remove use of the register keyword from
	the prototype.

libiberty/ChangeLog
2020-06-25  Nick Clifton  <nickc@redhat.com>

	* bsearch.c (bsearch): Remove use of register keyword.
	* bsearch_r.c (bsearch_r): Likewise.
diff --git a/include/libiberty.h b/include/libiberty.h
index 0bb5b81d4ac..591e9ac48d4 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -643,9 +643,9 @@ extern int pwait (int, int *, int);
 
 /* Like bsearch, but takes and passes on an argument like qsort_r.  */
 
-extern void *bsearch_r (register const void *, const void *,
-			size_t, register size_t,
-			register int (*)(const void *, const void *, void *),
+extern void *bsearch_r (const void *, const void *,
+			size_t, size_t,
+			int (*)(const void *, const void *, void *),
 			void *);
 
 #if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
diff --git a/libiberty/bsearch.c b/libiberty/bsearch.c
index 35fad19977c..18158b9591b 100644
--- a/libiberty/bsearch.c
+++ b/libiberty/bsearch.c
@@ -69,13 +69,13 @@ is respectively less than, matching, or greater than the array member.
  * look at item 3.
  */
 void *
-bsearch (register const void *key, const void *base0,
-         size_t nmemb, register size_t size,
-         register int (*compar)(const void *, const void *))
+bsearch (const void *key, const void *base0,
+         size_t nmemb, size_t size,
+         int (*compar)(const void *, const void *))
 {
-	register const char *base = (const char *) base0;
-	register int lim, cmp;
-	register const void *p;
+	const char *base = (const char *) base0;
+	int lim, cmp;
+	const void *p;
 
 	for (lim = nmemb; lim != 0; lim >>= 1) {
 		p = base + (lim >> 1) * size;
diff --git a/libiberty/bsearch_r.c b/libiberty/bsearch_r.c
index 79ebae9b0be..2a2ca6f5e23 100644
--- a/libiberty/bsearch_r.c
+++ b/libiberty/bsearch_r.c
@@ -70,14 +70,14 @@ is respectively less than, matching, or greater than the array member.
  * look at item 3.
  */
 void *
-bsearch_r (register const void *key, const void *base0,
-	   size_t nmemb, register size_t size,
-	   register int (*compar)(const void *, const void *, void *),
+bsearch_r (const void *key, const void *base0,
+	   size_t nmemb, size_t size,
+	   int (*compar)(const void *, const void *, void *),
 	   void *arg)
 {
-	register const char *base = (const char *) base0;
-	register int lim, cmp;
-	register const void *p;
+	const char *base = (const char *) base0;
+	int lim, cmp;
+	const void *p;
 
 	for (lim = nmemb; lim != 0; lim >>= 1) {
 		p = base + (lim >> 1) * size;
Ian Lance Taylor June 25, 2020, 4:54 p.m. | #3
Nick Clifton <nickc@redhat.com> writes:

> Hi Nick, Hi Ian, 

>>>     In file included from gold/archive.cc:29:

>>>     include/libiberty.h:646:25: error: 'register' storage class

>>>       specifier is deprecated and incompatible with C++17

>>>       [-Werror,-Wdeprecated-register]

>>>

>>>   So I would like to apply the patch below to fix this.  Is this OK ?

>> 

>> Yes please! This was copied straight from bsearch.c, so you probably

>> want to change bsearch.c and bsearch_r.c as well (just in case clang

>> ever finds itself needing to build bsearch_r out of libiberty).

>

> OK, here is a revised patch.  Ian - is this OK ?

>

> Cheers

>   Nick

>

> include/ChangeLog

> 2020-06-25  Nick Clifton  <nickc@redhat.com>

>

> 	* libiberty.h (bsearch_r): Remove use of the register keyword from

> 	the prototype.

>

> libiberty/ChangeLog

> 2020-06-25  Nick Clifton  <nickc@redhat.com>

>

> 	* bsearch.c (bsearch): Remove use of register keyword.

> 	* bsearch_r.c (bsearch_r): Likewise.


Sure, this is fine.

Thanks.

Ian
Jakub Jelinek via Gcc-patches June 26, 2020, 9:12 a.m. | #4
Hi Guys,

>> include/ChangeLog

>> 2020-06-25  Nick Clifton  <nickc@redhat.com>

>>

>> 	* libiberty.h (bsearch_r): Remove use of the register keyword from

>> 	the prototype.

>>

>> libiberty/ChangeLog

>> 2020-06-25  Nick Clifton  <nickc@redhat.com>

>>

>> 	* bsearch.c (bsearch): Remove use of register keyword.

>> 	* bsearch_r.c (bsearch_r): Likewise.

> 

> Sure, this is fine.


Committed.

Cheers
  Nick

Patch

diff --git a/include/libiberty.h b/include/libiberty.h
index 0bb5b81d4a..591e9ac48d 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -643,9 +643,9 @@  extern int pwait (int, int *, int);
 
 /* Like bsearch, but takes and passes on an argument like qsort_r.  */
 
-extern void *bsearch_r (register const void *, const void *,
-			size_t, register size_t,
-			register int (*)(const void *, const void *, void *),
+extern void *bsearch_r (const void *, const void *,
+			size_t, size_t,
+			int (*)(const void *, const void *, void *),
 			void *);
 
 #if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF