Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/stdx/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
#endif
#endif

#ifndef USING_ATTR_NS
#if defined(__clang__)
#define USING_ATTR_NS using clang:
#else
#define USING_ATTR_NS using gnu:
#endif
#endif

#ifndef ALWAYS_INLINE
#define ALWAYS_INLINE inline __attribute__((always_inline))
#endif
Expand All @@ -30,6 +38,10 @@
#define NEVER_INLINE __attribute__((noinline))
#endif

#ifndef FLATTEN
#define FLATTEN __attribute__((flatten))
#endif

#ifndef MUSTTAIL
#if defined(__clang__)
#define MUSTTAIL [[clang::musttail]]
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ add_tests(
byterator
cached
callable
compiler
concepts
conditional
ct_conversions
Expand Down
15 changes: 15 additions & 0 deletions test/compiler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdx/compiler.hpp>

#include <catch2/catch_test_macros.hpp>

TEST_CASE("using attribute namespace", "[compiler]") {
[[USING_ATTR_NS warn_unused_result]] auto f(int) -> int;
}

ALWAYS_INLINE auto f1(int) -> void;

TEST_CASE("NEVER_INLINE", "[compiler]") { NEVER_INLINE auto f2(int) -> void; }

TEST_CASE("FLATTEN", "[compiler]") { FLATTEN auto f3(int) -> void; }

ALWAYS_INLINE FLATTEN auto f4(int) -> void;