mirror of
https://github.com/boostorg/config.git
synced 2025-07-30 04:17:16 +02:00
Added BOOST_MAY_ALIAS and BOOST_NO_MAY_ALIAS macros.
The macros can be used to mark types that can alias other types (i.e. break C++ strict aliasing rules).
This commit is contained in:
@ -1262,6 +1262,18 @@ Usage example:
|
||||
]]
|
||||
[[`BOOST_ATTRIBUTE_UNUSED`][Expands to `__attribute__((unused))` when this is available -
|
||||
can be used to disable compiler warnings relating to unused types or variables.]]
|
||||
[[`BOOST_MAY_ALIAS`, `BOOST_NO_MAY_ALIAS`][
|
||||
`BOOST_MAY_ALIAS` expands to a type attribute that can be used to mark types that may
|
||||
alias other types. Pointers or references to such marked types can be used to access objects
|
||||
of other types. If the compiler supports this feature `BOOST_NO_MAY_ALIAS` is not defined.
|
||||
Otherwise `BOOST_MAY_ALIAS` expands to nothing and `BOOST_NO_MAY_ALIAS` is defined.
|
||||
|
||||
Usage example:
|
||||
``
|
||||
struct BOOST_MAY_ALIAS aliasing_struct;
|
||||
typedef unsigned int BOOST_MAY_ALIAS aliasing_uint;
|
||||
``
|
||||
]]
|
||||
]
|
||||
|
||||
[endsect]
|
||||
|
@ -318,6 +318,11 @@
|
||||
// Clang has supported the 'unused' attribute since the first release.
|
||||
#define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__))
|
||||
|
||||
// Type aliasing hint.
|
||||
#if __has_attribute(__may_alias__)
|
||||
# define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_COMPILER
|
||||
# define BOOST_COMPILER "Clang version " __clang_version__
|
||||
#endif
|
||||
|
@ -315,6 +315,10 @@
|
||||
#if __GNUC__ >= 4
|
||||
# define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__))
|
||||
#endif
|
||||
|
||||
// Type aliasing hint. Supported since gcc 3.3.
|
||||
#define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||
|
||||
//
|
||||
// __builtin_unreachable:
|
||||
#if BOOST_GCC_VERSION >= 40800
|
||||
|
@ -311,6 +311,12 @@ template<> struct assert_intrinsic_wchar_t<unsigned short> {};
|
||||
# define BOOST_SYMBOL_IMPORT
|
||||
# define BOOST_SYMBOL_VISIBLE __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
// Type aliasing hint
|
||||
#if defined(__GNUC__) && (BOOST_INTEL_CXX_VERSION >= 1300)
|
||||
# define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||
#endif
|
||||
|
||||
//
|
||||
// C++0x features
|
||||
// For each feature we need to check both the Intel compiler version,
|
||||
|
@ -65,6 +65,11 @@
|
||||
#define BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS
|
||||
#endif
|
||||
|
||||
// Type aliasing hint. Supported since XL C++ 13.1
|
||||
#if (__IBMCPP__ >= 1310)
|
||||
# define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||
#endif
|
||||
|
||||
//
|
||||
// C++0x features
|
||||
//
|
||||
|
@ -267,6 +267,11 @@
|
||||
# define BOOST_ATTRIBUTE_UNUSED __attribute__((unused))
|
||||
#endif
|
||||
|
||||
// Type aliasing hint.
|
||||
#if __has_attribute(__may_alias__)
|
||||
# define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_COMPILER
|
||||
# define BOOST_COMPILER "Clang version " __clang_version__
|
||||
#endif
|
||||
|
@ -159,6 +159,7 @@
|
||||
#if defined(__IBM_ATTRIBUTES)
|
||||
# define BOOST_FORCEINLINE inline __attribute__ ((__always_inline__))
|
||||
# define BOOST_NOINLINE __attribute__ ((__noinline__))
|
||||
# define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||
// No BOOST_ALIGNMENT - explicit alignment support is broken (V2R1).
|
||||
#endif
|
||||
|
||||
|
@ -602,6 +602,14 @@ namespace std{ using ::type_info; }
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// BOOST_MAY_ALIAS -----------------------------------------------//
|
||||
// The macro expands to an attribute to mark a type that is allowed to alias other types.
|
||||
// The macro is defined in the compiler-specific headers.
|
||||
#if !defined(BOOST_MAY_ALIAS)
|
||||
# define BOOST_NO_MAY_ALIAS
|
||||
# define BOOST_MAY_ALIAS
|
||||
#endif
|
||||
|
||||
// BOOST_FORCEINLINE ---------------------------------------------//
|
||||
// Macro to use in place of 'inline' to force a function to be inline
|
||||
#if !defined(BOOST_FORCEINLINE)
|
||||
|
@ -1152,6 +1152,8 @@ void print_boost_macros()
|
||||
PRINT_MACRO(BOOST_FORCEINLINE);
|
||||
PRINT_MACRO(BOOST_NOINLINE);
|
||||
PRINT_MACRO(BOOST_FALLTHROUGH);
|
||||
PRINT_MACRO(BOOST_MAY_ALIAS);
|
||||
PRINT_MACRO(BOOST_NO_MAY_ALIAS);
|
||||
}
|
||||
|
||||
void print_separator()
|
||||
|
@ -34,6 +34,9 @@ BOOST_NORETURN void always_throw()
|
||||
throw 0;
|
||||
}
|
||||
|
||||
struct BOOST_MAY_ALIAS aliasing_struct {};
|
||||
typedef unsigned int BOOST_MAY_ALIAS aliasing_uint;
|
||||
|
||||
|
||||
#define test_fallthrough(x) foobar(x)
|
||||
|
||||
|
Reference in New Issue
Block a user