From dfe501dde6d11de6535033fcc1612b444b1d0d05 Mon Sep 17 00:00:00 2001 From: drpriver Date: Fri, 18 Apr 2025 17:43:01 -0700 Subject: [PATCH] Fix #21267: ImportC: `__forceinline` ignored Fixes https://github.com/dlang/dmd/issues/21267 `__forceinline` is the same as `__attribute__((always_inline))`, so `#define` it to be the same. --- compiler/test/compilable/test21267.c | 4 ++++ druntime/src/importc.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 compiler/test/compilable/test21267.c diff --git a/compiler/test/compilable/test21267.c b/compiler/test/compilable/test21267.c new file mode 100644 index 0000000000..6bc355f232 --- /dev/null +++ b/compiler/test/compilable/test21267.c @@ -0,0 +1,4 @@ +// https://github.com/dlang/dmd/issues/21267 +static inline __forceinline int square(int x) { return x * x; } + +int doSquare(int x) { return square(x); } diff --git a/druntime/src/importc.h b/druntime/src/importc.h index dcca9ea5d4..9d8ceff4f0 100644 --- a/druntime/src/importc.h +++ b/druntime/src/importc.h @@ -56,7 +56,7 @@ */ #define __fastcall -#define __forceinline +#define __forceinline __attribute__((always_inline)) #undef _Check_return_ //#define _Check_return_ #define __pragma(x)