On Fri, May 23, 2025 at 12:33 PM Richard Biener <richard.guent...@gmail.com> wrote:
> > > Am 23.05.2025 um 18:32 schrieb Joel Sherrill <joel.sherr...@gmail.com>: > > > > > On Fri, May 23, 2025 at 10:12 AM Richard Biener < > richard.guent...@gmail.com> wrote: > >> >> >> > 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. >> > > Adding __extension__ did work. Thanks! > > Any idea if that's accepted by clang? > > > It should be accepted. Whether or not it has the same effect on > diagnostics I do not know. > > Do you think the GCC documentation on this should include this? > > > If __extension__ is not cross-referenced from the -pedantic documentation > we should probably do so. Can you propose a patch? > I'll add it to my queue. --joel > > Richard > > > --Joel Sherrill > >> >> Richard >> >> > >> > Thanks. >> > >> > --Joel Sherrill >> >