ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
OM_compiler_defs.h
Go to the documentation of this file.
1// Compiler diagnostic tweaks and C++03/C++11 compatibility macros for OMs
2#pragma once
3
4#define DO_PRAGMA(x) _Pragma(#x)
5#define CC_DIAGNOSTIC_PUSH() _Pragma("GCC diagnostic push")
6#define CC_DIAGNOSTIC_POP() _Pragma("GCC diagnostic pop")
7
8#define CC_DIAGNOSTIC_IGNORE_OM_LLVM_CHECKS() \
9 DO_PRAGMA(GCC diagnostic ignored "-Wreturn-type")
10
11// C++11+ syntax that is invalid under --std c++03 — elide it on the C++03 path.
12#if __cplusplus >= 201103L
13# define OM_CONSTEXPR constexpr
14# define OM_NOEXCEPT noexcept
15# define OM_NULLPTR nullptr
16#else
17# define OM_CONSTEXPR
18# define OM_NOEXCEPT
19# define OM_NULLPTR 0
20#endif
21
22// char_traits members became constexpr in C++17 (P0426R1); libc++ gates them
23// the same way, as _LIBCPP_CONSTEXPR_SINCE_CXX17. Starting earlier would let a
24// constexpr string_view built from a literal compile here but not under clang.
25#if __cplusplus >= 201703L
26# define OM_CONSTEXPR17 constexpr
27#else
28# define OM_CONSTEXPR17
29#endif
30
31// A static data member with an in-class initialiser. OM_CONSTEXPR alone is not
32// enough: eliding `constexpr` would leave a non-const member, which C++03 does
33// not let you initialise in-class. Only valid for integral and enum types.
34#if __cplusplus >= 201103L
35# define OM_STATIC_CONSTANT static constexpr
36#else
37# define OM_STATIC_CONSTANT static const
38#endif