-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__inline
causes header to fail to parse, when it succeeds in MSVC
#124869
Comments
@llvm/issue-subscribers-clang-frontend Author: Melvin Wang (wmmc88)
I was trying to parse a Windows header (`ufxclient.h`) using clang with the msvc compatibility flags (`-fms-compatibility -fms-extensions`) and ended up with the following error:
```
error: 'inline' can only appear on functions
```
I managed to narrow the issue down to several typdef definitions in the header that erroneously add
MSVC successfully compiles this definition, but clang fails with the above error, even with all the ms compatibility flags/extensions enabled. I think clang should loosen this error to a warning so that the code still compiles. Or should allow this completely when the ms-compat options are enabled. Minimal repros : Passing in MSVC: https://godbolt.org/z/59MYbebax |
Yeah, it seems defensible for us to simply drop the |
One thing that's interesting to note is that Microsoft only supports that in C, not in C++: https://godbolt.org/z/fYsrhsGPs |
Microsoft allows the 'inline' specifier on a typedef of a function type in C modes. This is used by a system header (ufxclient.h), so instead of giving a hard error, we diagnose with a warning. C++ mode and non- Microsoft compatibility modes are not impacted. Fixes llvm#124869
Microsoft allows the 'inline' specifier on a typedef of a function type in C modes. This is used by a system header (ufxclient.h), so instead of giving a hard error, we diagnose with a warning. C++ mode and non- Microsoft compatibility modes are not impacted. Fixes #124869
Thanks for the quick fix @AaronBallman! Am I correct in assuming that this change won't be released until LLVM 20? |
I think it's probably safe enough that we could backport it given that it impacts a system header. However, I'm a bit curious how a C++ compilation handles that header file given that MSVC gives an error on the construct. Did Microsoft already fix this on their end? |
…de (#125250) Microsoft allows the 'inline' specifier on a typedef of a function type in C modes. This is used by a system header (ufxclient.h), so instead of giving a hard error, we diagnose with a warning. C++ mode and non- Microsoft compatibility modes are not impacted. Fixes llvm/llvm-project#124869
I think the answer is that it doesn't. I was able to repro the issue you described when compiling for C++ with that header. I am not affiliated with any of the teams which own this, but I've let them know about it!
This would mean it'd be available in something like a v19.1.8? Is there going to be another v19 release? |
Thank you!
I don't think there will be any more 19.x releases; we just cut the branch for Clang 20 this week. So I'm porting to 20.x instead of it waiting for 21.x, but 19.x is going to be stuck I believe. CC @tstellar @tru in case they want to put out a 19.x given that this impacts a system header. |
…5250) Microsoft allows the 'inline' specifier on a typedef of a function type in C modes. This is used by a system header (ufxclient.h), so instead of giving a hard error, we diagnose with a warning. C++ mode and non- Microsoft compatibility modes are not impacted. Fixes llvm#124869
#125275) Microsoft allows the 'inline' specifier on a typedef of a function type in C modes. This is used by a system header (ufxclient.h), so instead of giving a hard error, we diagnose with a warning. C++ mode and non- Microsoft compatibility modes are not impacted. Fixes #124869 (cherry picked from commit ef91cae)
…de (#125250) (#125275) Microsoft allows the 'inline' specifier on a typedef of a function type in C modes. This is used by a system header (ufxclient.h), so instead of giving a hard error, we diagnose with a warning. C++ mode and non- Microsoft compatibility modes are not impacted. Fixes llvm/llvm-project#124869 (cherry picked from commit ef91cae)
I was trying to parse a Windows header (
ufxclient.h
) using clang with the msvc compatibility flags (-fms-compatibility -fms-extensions
) and ended up with the following error:I managed to narrow the issue down to several typdef definitions in the header that erroneously add
FORCEINLINE
to a function ptr typedef. This is one of them:MSVC successfully compiles this definition, but clang fails with the above error, even with all the ms compatibility flags/extensions enabled. I think clang should loosen this error to a warning so that the code still compiles. Or should allow this completely when the ms-compat options are enabled.
Minimal repros :
Passing in MSVC: https://godbolt.org/z/59MYbebax
Hard Error in Clang: https://godbolt.org/z/W8cs54oo6
Warning in Gcc, but still succeeds to compile: https://godbolt.org/z/Tbv7PsbKr
The text was updated successfully, but these errors were encountered: