> Am 23.05.2025 um 17:06 schrieb Joel Sherrill via Gcc <gcc@gcc.gnu.org>:
>
> Hi
>
> In the SPARC port of RTEMS, there is a global variable assigned to a
> register for performance reasons. This is the near decade old line of code:
>
> register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__( "g6" );
>
> Per https://gcc.gnu.org/onlinedocs/gcc/Global-Register-Variables.html, this
> is still the correct way to accomplish this. But -pedantic and specifying
> C17 result in this warning:
>
> ../../../cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h:230:17:
> warning: file-scope declaration of '_SPARC_Per_CPU_current' specifies
> 'register' [-Wpedantic]
> 230 | register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__(
> "g6" );
> |
>
> We do not want to move this pointer out of a register and the GCC docs
> section cited above doesn't mention anything about the register keyword
> being moved to reserved keyword in C17 and C++17 with undefined meaning.
> The example in the GCC manual is similar to our use.
>
> Is there more current guidance on having a global register variable? Other
> than disabling the pedantic warning around that one line, how should the
> warning be addressed?
Does it work by writing __extension__ before it? This is a GNU extension, so
complaining with -pedantic when compiling with -std=cXY as opposed to
-std=gnuXY is what I would expect.
Richard
>
> Thanks.
>
> --Joel Sherrill