forked from boostorg/config
Merge pull request #162 from Lastique/may_alias
Added BOOST_MAY_ALIAS and BOOST_NO_MAY_ALIAS macros.
This commit is contained in:
@ -1262,6 +1262,18 @@ Usage example:
|
|||||||
]]
|
]]
|
||||||
[[`BOOST_ATTRIBUTE_UNUSED`][Expands to `__attribute__((unused))` when this is available -
|
[[`BOOST_ATTRIBUTE_UNUSED`][Expands to `__attribute__((unused))` when this is available -
|
||||||
can be used to disable compiler warnings relating to unused types or variables.]]
|
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]
|
[endsect]
|
||||||
|
@ -318,6 +318,11 @@
|
|||||||
// Clang has supported the 'unused' attribute since the first release.
|
// Clang has supported the 'unused' attribute since the first release.
|
||||||
#define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__))
|
#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
|
#ifndef BOOST_COMPILER
|
||||||
# define BOOST_COMPILER "Clang version " __clang_version__
|
# define BOOST_COMPILER "Clang version " __clang_version__
|
||||||
#endif
|
#endif
|
||||||
|
@ -315,6 +315,10 @@
|
|||||||
#if __GNUC__ >= 4
|
#if __GNUC__ >= 4
|
||||||
# define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__))
|
# define BOOST_ATTRIBUTE_UNUSED __attribute__((__unused__))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Type aliasing hint. Supported since gcc 3.3.
|
||||||
|
#define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||||
|
|
||||||
//
|
//
|
||||||
// __builtin_unreachable:
|
// __builtin_unreachable:
|
||||||
#if BOOST_GCC_VERSION >= 40800
|
#if BOOST_GCC_VERSION >= 40800
|
||||||
|
@ -311,6 +311,12 @@ template<> struct assert_intrinsic_wchar_t<unsigned short> {};
|
|||||||
# define BOOST_SYMBOL_IMPORT
|
# define BOOST_SYMBOL_IMPORT
|
||||||
# define BOOST_SYMBOL_VISIBLE __attribute__((visibility("default")))
|
# define BOOST_SYMBOL_VISIBLE __attribute__((visibility("default")))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Type aliasing hint
|
||||||
|
#if defined(__GNUC__) && (BOOST_INTEL_CXX_VERSION >= 1300)
|
||||||
|
# define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// C++0x features
|
// C++0x features
|
||||||
// For each feature we need to check both the Intel compiler version,
|
// For each feature we need to check both the Intel compiler version,
|
||||||
|
@ -65,6 +65,11 @@
|
|||||||
#define BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS
|
#define BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Type aliasing hint. Supported since XL C++ 13.1
|
||||||
|
#if (__IBMCPP__ >= 1310)
|
||||||
|
# define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// C++0x features
|
// C++0x features
|
||||||
//
|
//
|
||||||
|
@ -267,6 +267,11 @@
|
|||||||
# define BOOST_ATTRIBUTE_UNUSED __attribute__((unused))
|
# define BOOST_ATTRIBUTE_UNUSED __attribute__((unused))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Type aliasing hint.
|
||||||
|
#if __has_attribute(__may_alias__)
|
||||||
|
# define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef BOOST_COMPILER
|
#ifndef BOOST_COMPILER
|
||||||
# define BOOST_COMPILER "Clang version " __clang_version__
|
# define BOOST_COMPILER "Clang version " __clang_version__
|
||||||
#endif
|
#endif
|
||||||
|
@ -159,6 +159,7 @@
|
|||||||
#if defined(__IBM_ATTRIBUTES)
|
#if defined(__IBM_ATTRIBUTES)
|
||||||
# define BOOST_FORCEINLINE inline __attribute__ ((__always_inline__))
|
# define BOOST_FORCEINLINE inline __attribute__ ((__always_inline__))
|
||||||
# define BOOST_NOINLINE __attribute__ ((__noinline__))
|
# define BOOST_NOINLINE __attribute__ ((__noinline__))
|
||||||
|
# define BOOST_MAY_ALIAS __attribute__((__may_alias__))
|
||||||
// No BOOST_ALIGNMENT - explicit alignment support is broken (V2R1).
|
// No BOOST_ALIGNMENT - explicit alignment support is broken (V2R1).
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -602,6 +602,14 @@ namespace std{ using ::type_info; }
|
|||||||
# endif
|
# endif
|
||||||
#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 ---------------------------------------------//
|
// BOOST_FORCEINLINE ---------------------------------------------//
|
||||||
// Macro to use in place of 'inline' to force a function to be inline
|
// Macro to use in place of 'inline' to force a function to be inline
|
||||||
#if !defined(BOOST_FORCEINLINE)
|
#if !defined(BOOST_FORCEINLINE)
|
||||||
|
@ -1152,6 +1152,8 @@ void print_boost_macros()
|
|||||||
PRINT_MACRO(BOOST_FORCEINLINE);
|
PRINT_MACRO(BOOST_FORCEINLINE);
|
||||||
PRINT_MACRO(BOOST_NOINLINE);
|
PRINT_MACRO(BOOST_NOINLINE);
|
||||||
PRINT_MACRO(BOOST_FALLTHROUGH);
|
PRINT_MACRO(BOOST_FALLTHROUGH);
|
||||||
|
PRINT_MACRO(BOOST_MAY_ALIAS);
|
||||||
|
PRINT_MACRO(BOOST_NO_MAY_ALIAS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_separator()
|
void print_separator()
|
||||||
|
@ -34,6 +34,9 @@ BOOST_NORETURN void always_throw()
|
|||||||
throw 0;
|
throw 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct BOOST_MAY_ALIAS aliasing_struct {};
|
||||||
|
typedef unsigned int BOOST_MAY_ALIAS aliasing_uint;
|
||||||
|
|
||||||
|
|
||||||
#define test_fallthrough(x) foobar(x)
|
#define test_fallthrough(x) foobar(x)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user