Skip to content
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

intellisense does not recognize __builtin_preserve_access_index return type #6659

Closed
giladreti opened this issue Dec 13, 2020 · 4 comments
Closed
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service Visual Studio Inherited from Visual Studio
Milestone

Comments

@giladreti
Copy link

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.

@sean-mcmanus sean-mcmanus self-assigned this Dec 14, 2020
@sean-mcmanus
Copy link
Collaborator

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 sean-mcmanus added this to the Tracking milestone Dec 14, 2020
@sean-mcmanus sean-mcmanus added bug Language Service Visual Studio Inherited from Visual Studio labels Dec 14, 2020
@sean-mcmanus sean-mcmanus removed their assignment Dec 14, 2020
@jacobwgillespie
Copy link

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?

@sean-mcmanus
Copy link
Collaborator

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 sean-mcmanus modified the milestones: Tracking, 1.12.0 Jul 18, 2022
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Jul 18, 2022
@sean-mcmanus
Copy link
Collaborator

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

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service Visual Studio Inherited from Visual Studio
Projects
None yet
Development

No branches or pull requests

3 participants