vscode-cpptools
vscode-cpptools copied to clipboard
intellisense does not recognize __builtin_preserve_access_index return type
Type: LanguageService
Describe the bug
- OS and Version: Linux Ubuntu 5.10-rc6
- VS Code Version: 1.51.1, e5a624b788d92b8d34d1392e4c4d9789406efe8f, x64
- C/C++ Extension Version: v1.1.3
- c_cpp_properties:
...
"configurations": [
{
"name": "test",
"intelliSenseMode": "clang-x64",
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++20",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
Intellisense recognizes clang's __builtin_preserve_access_index return type to be simply void, thus generating errors of invalid type conversions etc.
For example, the following generates a type error of a value of type "void" cannot be used to initialize an entity of type "int"C/C++(144) :
struct test_struct
{
int test_attr;
};
struct test_struct instance = {.test_attr = 0};
struct test_struct *instance_ptr = &instance;
int a = __builtin_preserve_access_index(instance_ptr->test_attr);
Expected behavior
intellisense should recognize the return type as the type of the argument.
Thanks for reporting this. I've filed a bug against our parser shared with VS: https://developercommunity.visualstudio.com/content/problem/1287445/c-intellisense-shows-builtin-preserve-access-index.html
I am encountering this error as well working with code using libbpf - is there any workaround that would at least silence the error in VS Code?
You could try to something like
#ifdef __INTELLISENSE__
#pragma diag_suppress <error code>
#endif
depending on what error code you're getting. Or define something else in an INTELLISENSE block.
Fixed with 1.12.0 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.12.0