diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-12-11 13:57:31 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-12-12 11:35:22 +0100 |
commit | fcd9618ac84e04d363741419e67b5d618ebe6a81 (patch) | |
tree | 66ae994cfc773d414c8551f08a0baab21b10e507 /cpukit/include/rtems/confdefs/inittask.h | |
parent | bsps/gicv3: Resolve build warnings on 64bit (diff) | |
download | rtems-fcd9618ac84e04d363741419e67b5d618ebe6a81.tar.bz2 |
config: Fix invalid static assertions in C
Expressions in static assertions must be integral constant expressions. In
integral constant expressions the use of address constant expressions is not
allowed.
In static initializers the address constant expressions are allowed. Introduce
a new macro _CONFIGURE_ASSERT_NOT_NULL() which leads to a compile time error if
the second parameter is NULL. It generates error messages like this if for
example
#define CONFIGURE_INIT_TASK_ENTRY_POINT NULL
is provided by the application:
cpukit/include/rtems/confdefs/inittask.h:51:26: error: size of unnamed array is negative
51 | ( _type ) sizeof( int[ ( _value ) != NULL ? 1 : -1 ] ) )
| ^
cpukit/include/rtems/confdefs/inittask.h:170:3: note: in expansion of macro '_CONFIGURE_ASSERT_NOT_NULL'
170 | _CONFIGURE_ASSERT_NOT_NULL(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
This fix relates to CID 1470570 (PARSE_ERROR).
Update #4181.
Diffstat (limited to 'cpukit/include/rtems/confdefs/inittask.h')
-rw-r--r-- | cpukit/include/rtems/confdefs/inittask.h | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/cpukit/include/rtems/confdefs/inittask.h b/cpukit/include/rtems/confdefs/inittask.h index d5ba521bf9..9dbf0b967b 100644 --- a/cpukit/include/rtems/confdefs/inittask.h +++ b/cpukit/include/rtems/confdefs/inittask.h @@ -46,6 +46,10 @@ #ifdef CONFIGURE_INIT +#define _CONFIGURE_ASSERT_NOT_NULL( _type, _value ) \ + ( ( _value ) != NULL ? ( _value ) : \ + ( _type ) sizeof( int[ ( _value ) != NULL ? 1 : -1 ] ) ) + #ifdef CONFIGURE_RTEMS_INIT_TASKS_TABLE #include <rtems/confdefs/percpu.h> @@ -94,8 +98,8 @@ extern "C" { #endif /* - * Ignore the following warnings from g++ and clang in the static assertion - * below: + * Ignore the following warnings from g++ and clang in the uses of + * _CONFIGURE_ASSERT_NOT_NULL() below: * * warning: the address of 'void Init()' will never be NULL [-Waddress] * @@ -107,13 +111,6 @@ extern "C" { #pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wtautological-pointer-compare" -RTEMS_STATIC_ASSERT( - CONFIGURE_INIT_TASK_ENTRY_POINT != NULL, - CONFIGURE_INIT_TASK_ENTRY_POINT_MUST_NOT_BE_NULL -); - -#pragma GCC diagnostic pop - #ifdef CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE #ifdef CONFIGURE_INIT_TASK_STACK_SIZE @@ -139,7 +136,10 @@ const RTEMS_tasks_User_task_config _RTEMS_tasks_User_task_config = { CONFIGURE_INIT_TASK_INITIAL_MODES, CONFIGURE_INIT_TASK_ATTRIBUTES, }, - CONFIGURE_INIT_TASK_ENTRY_POINT, + _CONFIGURE_ASSERT_NOT_NULL( + rtems_task_entry, + CONFIGURE_INIT_TASK_ENTRY_POINT + ), CONFIGURE_INIT_TASK_ARGUMENTS }; @@ -167,7 +167,10 @@ const rtems_initialization_tasks_table _RTEMS_tasks_User_task_table = { CONFIGURE_INIT_TASK_STACK_SIZE, CONFIGURE_INIT_TASK_PRIORITY, CONFIGURE_INIT_TASK_ATTRIBUTES, - CONFIGURE_INIT_TASK_ENTRY_POINT, + _CONFIGURE_ASSERT_NOT_NULL( + rtems_task_entry, + CONFIGURE_INIT_TASK_ENTRY_POINT + ), CONFIGURE_INIT_TASK_INITIAL_MODES, CONFIGURE_INIT_TASK_ARGUMENTS }; @@ -180,6 +183,8 @@ RTEMS_SYSINIT_ITEM( #endif /* CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE */ +#pragma GCC diagnostic pop + #ifdef __cplusplus } #endif |