| 1 |
// PR c++/95222 |
| 2 |
// { dg-do compile { target { { { i?86-*-* x86_64-*-* } && ia32 } && c++11 } } } |
| 3 |
|
| 4 |
#if defined(_MSC_VER) |
| 5 |
#define CC_FASTCALL __fastcall |
| 6 |
#define CC_STDCALL __stdcall |
| 7 |
#else |
| 8 |
#define CC_FASTCALL __attribute__((fastcall)) |
| 9 |
#define CC_STDCALL __attribute__((stdcall)) |
| 10 |
#endif |
| 11 |
|
| 12 |
template <typename FuncT> |
| 13 |
struct FuncResult; |
| 14 |
|
| 15 |
template <typename R, typename... Args> |
| 16 |
struct FuncResult<R(*)(Args...)> |
| 17 |
{ |
| 18 |
using type = R; |
| 19 |
}; |
| 20 |
|
| 21 |
template <typename R, typename... Args> |
| 22 |
struct FuncResult<R(CC_FASTCALL*)(Args...)> |
| 23 |
{ |
| 24 |
using type = R; |
| 25 |
}; |
| 26 |
|
| 27 |
template <typename R, typename... Args> |
| 28 |
struct FuncResult<R(CC_STDCALL*)(Args...)> |
| 29 |
{ |
| 30 |
using type = R; |
| 31 |
}; |
| 32 |
|
| 33 |
template <typename FuncT> |
| 34 |
auto wrap(FuncT f) -> typename FuncResult<FuncT>::type |
| 35 |
{ |
| 36 |
return f(1, 2, 3); |
| 37 |
} |
| 38 |
|
| 39 |
int CC_FASTCALL func1(int x, int y, int z) |
| 40 |
{ |
| 41 |
return x + y + z; |
| 42 |
} |
| 43 |
|
| 44 |
int CC_STDCALL func2(int x, int y, int z) |
| 45 |
{ |
| 46 |
return x + y + z; |
| 47 |
} |
| 48 |
|
| 49 |
int main() |
| 50 |
{ |
| 51 |
return wrap(&func1) + wrap(&func2); |
| 52 |
} |