mirror of https://github.com/ARMmbed/mbed-os.git
mbed_toolchain: Use C++11/C11 attributes
Newer language standards have standard forms for `MBED_NORETURN` and `MBED_ALIGN` attributes. Use them when available. C++14 also adds `[[deprecated]]`, but as it needs to go in the middle of structure definitions as `class [[deprecated]] MyClass`, it's not a total drop-in-replacemend for `MBED_DEPRECATED`, so that is not attempted here. Using standard forms increases the chances that code analysis tools such Coverity will recognise them - particularly important for "no return".pull/10837/head
parent
56a043cbd1
commit
703af8df06
|
|
@ -72,7 +72,11 @@
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef MBED_ALIGN
|
#ifndef MBED_ALIGN
|
||||||
#if defined(__ICCARM__)
|
#if __cplusplus >= 201103 && !defined __CC_ARM
|
||||||
|
#define MBED_ALIGN(N) alignas(N)
|
||||||
|
#elif __STDC_VERSION__ >= 201112 && !defined __CC_ARM
|
||||||
|
#define MBED_ALIGN(N) _Alignas(N)
|
||||||
|
#elif defined(__ICCARM__)
|
||||||
#define MBED_ALIGN(N) _Pragma(MBED_STRINGIFY(data_alignment=N))
|
#define MBED_ALIGN(N) _Pragma(MBED_STRINGIFY(data_alignment=N))
|
||||||
#else
|
#else
|
||||||
#define MBED_ALIGN(N) __attribute__((aligned(N)))
|
#define MBED_ALIGN(N) __attribute__((aligned(N)))
|
||||||
|
|
@ -298,7 +302,11 @@
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#ifndef MBED_NORETURN
|
#ifndef MBED_NORETURN
|
||||||
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
|
#if __cplusplus >= 201103
|
||||||
|
#define MBED_NORETURN [[noreturn]]
|
||||||
|
#elif __STDC_VERSION__ >= 201112
|
||||||
|
#define MBED_NORETURN _Noreturn
|
||||||
|
#elif defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)
|
||||||
#define MBED_NORETURN __attribute__((noreturn))
|
#define MBED_NORETURN __attribute__((noreturn))
|
||||||
#elif defined(__ICCARM__)
|
#elif defined(__ICCARM__)
|
||||||
#define MBED_NORETURN __noreturn
|
#define MBED_NORETURN __noreturn
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue