microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.46k stars 1.53k forks source link

Can't get code suggestions of Struct member in some special situations. #10777

Open tooyangtoonaive opened 1 year ago

tooyangtoonaive commented 1 year ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: Can't get code suggestions of Struct member in some special situations.

Steps to reproduce:

main.h

#pragma once
#include <stdint.h>

typedef struct
{
    uint32_t a;
    uint8_t b;
}asd_t;

main.c


#include <stdio.h>
#include <string.h>
#include "main.h"
#include <stdlib.h>

void te(void)
{
    uint32_t val = 0;
    asd_t tmp;

    memset(&tmp, 0, sizeof(tmp));

    //tmp. can suggest here

    val = val + 1024;

    //tmp. can't suggest here

    val += 1024;

    //tmp. can suggest here

    val = val - 1024;

    //tmp. can't suggest here

    val++;

    //tmp. can suggest here

    val = val - 1;

    //tmp. can suggest here
}

Expected behavior: Input "tmp." should suggest member tmp.a and tmp.b in anywhere

Configuration and Logs

-------- Diagnostics - 2023/4/6 17:32:42
Version: 1.14.5
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "c:\\Users\\myname\\Desktop\\c_test/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "intelliSenseModeIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPath": "D:\\Users\\myname.mycompany\\programs\\Cygwin\\bin\\g++.exe",
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ C:\Users\myname\Desktop\c_test\main.c ]:
    C:\Users\myname\Desktop\c_test\main.c
    C:\Users\myname\Desktop\c_test\main.h *
Translation Unit Configurations:
[ C:\Users\myname\Desktop\c_test\main.c ]:
    Process ID: 70484
    Memory Usage: 52 MB
    Compiler Path: D:\Users\myname.mycompany\programs\Cygwin\bin\g++.exe
    Includes:
        D:\Users\myname.mycompany\programs\Cygwin\usr\include
        D:\Users\myname.mycompany\programs\Cygwin\usr\include\c++\v1
        D:\Users\myname.mycompany\programs\Cygwin\lib\gcc\x86_64-pc-cygwin\11\include
        D:\Users\myname.mycompany\programs\Cygwin\usr\include\w32api
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c17
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=110300
Total Memory Usage: 52 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 3010
Number of files parsed: 688

------- Potential include path issues --------
Some headers exist in multiple locations. If IntelliSense is behaving incorrectly,
try adding one of the alternate paths to the "includePath" in your configuration in
c_cpp_properties.json to override the automatic path discovery for that header.

Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/c++/v1/__config
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/c++/v1/experimental"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/endian.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/bits"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/machine"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/features.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/lib/gcc/x86_64-pc-cygwin/11/include/c++/parallel"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/sys"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/limits.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/lib/gcc/x86_64-pc-cygwin/11/include"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/lib/gcc/x86_64-pc-cygwin/11/include/c++/tr1"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/lib/gcc/x86_64-pc-cygwin/11/install-tools/include"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/c++/v1"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/c++/v1/support/ibm"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/cygwin"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/stdio.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/ssp"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/stdlib.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/lib/gcc/x86_64-pc-cygwin/11/include/c++"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/strings.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/cbor"

Other Extensions

No

Additional context

No response

browntarik commented 1 year ago

It looks like this is an error with Visual Studio as we share the same IntelliSense codebase, I will be filing a bug against their source as that is where the fix will be. You can track this issue to see when it is fixed by the VS team. (1800809)