Skip to content

Commit 75a270e

Browse files
Honor deprecation of register keyword in C++17 when building with GCC/Clang
1 parent ae4f50d commit 75a270e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: system/CMSIS/CMSIS/Include/core_cmFunc.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,13 @@ static __INLINE void __set_FPSCR(uint32_t fpscr)
300300
#elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
301301
/* GNU gcc specific functions */
302302

303+
/* C++17 removes register keyword */
304+
#if __cplusplus >= 201703L
305+
# define DEPRECATED_REGISTER
306+
#else
307+
# define DEPRECATED_REGISTER register
308+
#endif
309+
303310
/** \brief Enable IRQ Interrupts
304311
305312
This function enables IRQ interrupts by clearing the I-bit in the CPSR.
@@ -402,7 +409,7 @@ __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_xPSR(void)
402409
*/
403410
__attribute__( ( always_inline ) ) static __INLINE uint32_t __get_PSP(void)
404411
{
405-
register uint32_t result;
412+
DEPRECATED_REGISTER uint32_t result;
406413

407414
__ASM volatile ("MRS %0, psp\n" : "=r" (result) );
408415
return(result);
@@ -429,7 +436,7 @@ __attribute__( ( always_inline ) ) static __INLINE void __set_PSP(uint32_t topOf
429436
*/
430437
__attribute__( ( always_inline ) ) static __INLINE uint32_t __get_MSP(void)
431438
{
432-
register uint32_t result;
439+
DEPRECATED_REGISTER uint32_t result;
433440

434441
__ASM volatile ("MRS %0, msp\n" : "=r" (result) );
435442
return(result);
@@ -591,6 +598,8 @@ __attribute__( ( always_inline ) ) static __INLINE void __set_FPSCR(uint32_t fps
591598

592599
#endif /* (__CORTEX_M == 0x04) */
593600

601+
#undef DEPRECATED_REGISTER
602+
594603

595604
#elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
596605
/* TASKING carm specific functions */

0 commit comments

Comments
 (0)