libgomp: Fix build for -fshort-enums

Message ID 20230522125149.30467-1-sebastian.huber@embedded-brains.de
State New
Headers
Series libgomp: Fix build for -fshort-enums |

Commit Message

Sebastian Huber May 22, 2023, 12:51 p.m. UTC
  Make sure that the API enums have at least the size of int.  Otherwise the
following build error may occur:

In file included from gcc/libgomp/env.c:34:
./libgomp_f.h: In function 'omp_check_defines':
./libgomp_f.h:77:8: error: size of array 'test' is negative
   77 |   char test[(28 != sizeof (omp_lock_t)
      |        ^~~~

libgomp/ChangeLog:

	* omp.h.in (omp_alloctrait_key_t):  Add __omp_alloctrait_key_t_max__
	with a value of the int type maximum.
---
 libgomp/omp.h.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Sebastian Huber July 4, 2023, 6:20 a.m. UTC | #1
On 22.05.23 14:51, Sebastian Huber wrote:
> Make sure that the API enums have at least the size of int.  Otherwise the
> following build error may occur:
> 
> In file included from gcc/libgomp/env.c:34:
> ./libgomp_f.h: In function 'omp_check_defines':
> ./libgomp_f.h:77:8: error: size of array 'test' is negative
>     77 |   char test[(28 != sizeof (omp_lock_t)
>        |        ^~~~
> 
> libgomp/ChangeLog:
> 
> 	* omp.h.in (omp_alloctrait_key_t):  Add __omp_alloctrait_key_t_max__
> 	with a value of the int type maximum.
> ---
>   libgomp/omp.h.in | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
> index bd1286c2a3f..3b1612fcb15 100644
> --- a/libgomp/omp.h.in
> +++ b/libgomp/omp.h.in
> @@ -146,7 +146,8 @@ typedef enum omp_alloctrait_key_t
>     omp_atk_fallback = 5,
>     omp_atk_fb_data = 6,
>     omp_atk_pinned = 7,
> -  omp_atk_partition = 8
> +  omp_atk_partition = 8,
> +  __omp_alloctrait_key_t_max__ = __INT_MAX__
>   } omp_alloctrait_key_t;
>   
>   typedef enum omp_alloctrait_value_t

Could someone please have a look at this.
  
Sebastian Huber Sept. 11, 2023, 12:57 p.m. UTC | #2
On 04.07.23 08:20, Sebastian Huber wrote:
> On 22.05.23 14:51, Sebastian Huber wrote:
>> Make sure that the API enums have at least the size of int.  Otherwise 
>> the
>> following build error may occur:
>>
>> In file included from gcc/libgomp/env.c:34:
>> ./libgomp_f.h: In function 'omp_check_defines':
>> ./libgomp_f.h:77:8: error: size of array 'test' is negative
>>     77 |   char test[(28 != sizeof (omp_lock_t)
>>        |        ^~~~
>>
>> libgomp/ChangeLog:
>>
>>     * omp.h.in (omp_alloctrait_key_t):  Add __omp_alloctrait_key_t_max__
>>     with a value of the int type maximum.
>> ---
>>   libgomp/omp.h.in | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
>> index bd1286c2a3f..3b1612fcb15 100644
>> --- a/libgomp/omp.h.in
>> +++ b/libgomp/omp.h.in
>> @@ -146,7 +146,8 @@ typedef enum omp_alloctrait_key_t
>>     omp_atk_fallback = 5,
>>     omp_atk_fb_data = 6,
>>     omp_atk_pinned = 7,
>> -  omp_atk_partition = 8
>> +  omp_atk_partition = 8,
>> +  __omp_alloctrait_key_t_max__ = __INT_MAX__
>>   } omp_alloctrait_key_t;
>>   typedef enum omp_alloctrait_value_t
> 
> Could someone please have a look at this.

Ping.
  
Sebastian Huber Jan. 19, 2024, 9:55 a.m. UTC | #3
On 11.09.23 14:57, Sebastian Huber wrote:
> On 04.07.23 08:20, Sebastian Huber wrote:
>> On 22.05.23 14:51, Sebastian Huber wrote:
>>> Make sure that the API enums have at least the size of int.  
>>> Otherwise the
>>> following build error may occur:
>>>
>>> In file included from gcc/libgomp/env.c:34:
>>> ./libgomp_f.h: In function 'omp_check_defines':
>>> ./libgomp_f.h:77:8: error: size of array 'test' is negative
>>>     77 |   char test[(28 != sizeof (omp_lock_t)
>>>        |        ^~~~
>>>
>>> libgomp/ChangeLog:
>>>
>>>     * omp.h.in (omp_alloctrait_key_t):  Add __omp_alloctrait_key_t_max__
>>>     with a value of the int type maximum.
>>> ---
>>>   libgomp/omp.h.in | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
>>> index bd1286c2a3f..3b1612fcb15 100644
>>> --- a/libgomp/omp.h.in
>>> +++ b/libgomp/omp.h.in
>>> @@ -146,7 +146,8 @@ typedef enum omp_alloctrait_key_t
>>>     omp_atk_fallback = 5,
>>>     omp_atk_fb_data = 6,
>>>     omp_atk_pinned = 7,
>>> -  omp_atk_partition = 8
>>> +  omp_atk_partition = 8,
>>> +  __omp_alloctrait_key_t_max__ = __INT_MAX__
>>>   } omp_alloctrait_key_t;
>>>   typedef enum omp_alloctrait_value_t
>>
>> Could someone please have a look at this.
> 
> Ping.

Any chance to get this integrated for GCC 14?
  

Patch

diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
index bd1286c2a3f..3b1612fcb15 100644
--- a/libgomp/omp.h.in
+++ b/libgomp/omp.h.in
@@ -146,7 +146,8 @@  typedef enum omp_alloctrait_key_t
   omp_atk_fallback = 5,
   omp_atk_fb_data = 6,
   omp_atk_pinned = 7,
-  omp_atk_partition = 8
+  omp_atk_partition = 8,
+  __omp_alloctrait_key_t_max__ = __INT_MAX__
 } omp_alloctrait_key_t;
 
 typedef enum omp_alloctrait_value_t