This is an archive of the discontinued LLVM Phabricator instance.

Fix PR#62594 : static lambda call operator is not convertible to function pointer on win32
ClosedPublic

Authored by faisalv on May 7 2023, 2:11 PM.

Details

Summary

See issue https://github.com/llvm/llvm-project/issues/62594

This code does not work on win32:

cpp
  auto lstatic = []()  static  { return 0;  };
  int (*f2)(void) = lstatic;

Since a calling convention such as CC_X86ThisCall can rightly interfere with the implicit pointer to function conversion if erroneously marked on a static function, the fix entails checking the 'static' specifier on the lambda declarator prior to assigning it a calling convention of an non-static member (which pre-c++23 made sense).

Diff Detail

Event Timeline

faisalv created this revision.May 7 2023, 2:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 7 2023, 2:11 PM
Herald added a subscriber: pengfei. · View Herald Transcript
faisalv requested review of this revision.May 7 2023, 2:11 PM
inclyc added a subscriber: inclyc.May 8 2023, 1:13 AM

Can you also add a release note for the fix? The changes generally LGTM

clang/test/SemaCXX/cxx23-static-callop-lambda-expression.cpp
12
33

Please add the newline to the file.

shafik accepted this revision.May 8 2023, 11:43 AM

LGTM

This revision is now accepted and ready to land.May 8 2023, 11:43 AM

@shafik @aaron.ballman does any of you want to commandeer this diff? seems simple enough of a change

@shafik @aaron.ballman does any of you want to commandeer this diff? seems simple enough of a change

I think Aaron might be better since he is more familiar with Windows.