https://bugs.llvm.org/show_bug.cgi?id=47372

            Bug ID: 47372
           Summary: lambda static invoker does not inherit calling
                    convention attribute from operator()
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

Testcase:

auto f(int a, int b) [[gnu::cdecl]] { return a + b; }
auto g(int a, int b) [[gnu::regcall]] { return a + b; }

auto p = [](int a, int b) [[gnu::cdecl]] { return a + b; };
auto q = [](int a, int b) [[gnu::regcall]] { return a + b; };

auto x = &decltype(p)::operator();
auto y = &decltype(q)::operator();
void *z[2] = {&x, &y};

auto *static_x = +p;
auto *static_y = +q;

https://godbolt.org/z/ss68Y6

... uses regcall calling convention for g and q's operator(), but not for q's
static invoker. Indeed,

int (*static_x_regcall)(int, int) [[gnu::regcall]] = q;

... is rejected because there's no conversion function to a function pointer
with the right calling convention.

We should decide whether we want an explicit calling convention attribute on
the operator() to carry through to the conversion function. (If we fix PR38285
first, this should only affect the "default" calling convention used by (eg)
decaying a lambda to a function pointer with unary + or *.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to