vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

intellisense does not recognize __builtin_preserve_access_index return type

Open giladreti opened this issue 4 years ago • 4 comments

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.

giladreti avatar Dec 13 '20 12:12 giladreti

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

sean-mcmanus avatar Dec 14 '20 22:12 sean-mcmanus

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?

jacobwgillespie avatar Mar 13 '22 21:03 jacobwgillespie

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.

sean-mcmanus avatar Mar 14 '22 17:03 sean-mcmanus

Fixed with 1.12.0 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.12.0

sean-mcmanus avatar Jul 28 '22 17:07 sean-mcmanus