microsoft / vscode-cpptools

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

Support multidimensional array subscript operator with windows-clang-x64 #11400

Open BluTree opened 1 year ago

BluTree commented 1 year ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: The C++23 standard support multidimensional array subscript (i.e operator[](int a, int b)), but the C++ extension outputs errors even with the cppStandard to c++23 and with a compatible compiler (clang 16).

Steps to reproduce:

  1. Create a file containing this snippet :

    
    struct A
    {
    int& operator[](int x, int y)
    {
        return _data[x * 3 + y];
    }
    
    int _data[9] {0};
    };

int main() { A a;

a[0, 0] = 0;

}

2. Set the c++ standard to 23 and compiler to clang
4. Notice the error, while it compiles with -std=c++2b on the file

Expected behavior:
No error

### Configuration and Logs

```shell
-------- Diagnostics - 9/3/2023, 4:32:28 PM
Version: 1.17.5
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "c:/Dev/Sources/YetAnotherEngine/src/**",
        "c:/Dev/Sources/YetAnotherEngine/lib/*",
        "c:/Dev/Sources/YetAnotherEngine/lib/imgui/*",
        "c:/Dev/Sources/YetAnotherEngine/lib/glfw/include/*"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "intelliSenseMode": "windows-clang-x64",
    "cppStandard": "c++23",
    "compilerArgs": [],
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "mergeConfigurations": false,
    "compilerPath": "C:\\Dev\\LLVM\\bin\\clang.exe",
    "browse": {
        "path": [
            "c:/Dev/Sources/YetAnotherEngine/src/**",
            "c:/Dev/Sources/YetAnotherEngine/lib/*",
            "c:/Dev/Sources/YetAnotherEngine/lib/imgui/*",
            "c:/Dev/Sources/YetAnotherEngine/lib/glfw/include/*",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
cpptools version (native): 1.17.5.0
Translation Unit Mappings:
[ C:\Dev\Sources\YetAnotherEngine\src\Core\Math\Vector\Vector2.cpp ]:
    C:\Dev\Sources\YetAnotherEngine\src\Core\Math\Vector\Vector2.h *
[ C:\Dev\Sources\YetAnotherEngine\src\Core\Math\Matrix\Matrix3.cpp ]:
    C:\Dev\Sources\YetAnotherEngine\src\Core\Math\Matrix\Matrix3.cpp
    C:\Dev\Sources\YetAnotherEngine\src\Core\Math\Matrix\Matrix3.h *
[ C:\Dev\Sources\YetAnotherEngine\src\main.cpp ]:
    C:\Dev\Sources\YetAnotherEngine\src\main.cpp
Translation Unit Configurations:
[ C:\Dev\Sources\YetAnotherEngine\src\Core\Math\Vector\Vector2.cpp ]:
    Process ID: 19356
    Memory Usage: 132 MB
    Compiler Path: C:\Dev\LLVM\bin\clang.exe
    Includes:
        C:\Dev\Sources\YetAnotherEngine\lib
        C:\Dev\Sources\YetAnotherEngine\lib\imgui
        C:\Dev\Sources\YetAnotherEngine\lib\glfw\include
        C:\Dev\LLVM\lib\clang\16\include
        C:\Dev\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include
        C:\Dev\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\atlmfc\include
        C:\Windows Kits\10\Include\10.0.22000.0\ucrt
        C:\Windows Kits\10\Include\10.0.22000.0\shared
        C:\Windows Kits\10\Include\10.0.22000.0\um
        C:\Windows Kits\10\Include\10.0.22000.0\winrt
        C:\Windows Kits\10\Include\10.0.22000.0\cppwinrt
        C:\Dev\Sources\YetAnotherEngine\src
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c++23
    IntelliSense Mode: windows-clang-x64
    Other Flags:
        --clang
        --clang_version=160000
        --ms_compatibility
[ C:\Dev\Sources\YetAnotherEngine\src\Core\Math\Matrix\Matrix3.cpp ]:
    Process ID: 23312
    Memory Usage: 59 MB
    Compiler Path: C:\Dev\LLVM\bin\clang.exe
    Includes:
        C:\Dev\Sources\YetAnotherEngine\lib
        C:\Dev\Sources\YetAnotherEngine\lib\imgui
        C:\Dev\Sources\YetAnotherEngine\lib\glfw\include
        C:\Dev\LLVM\lib\clang\16\include
        C:\Dev\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include
        C:\Dev\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\atlmfc\include
        C:\Windows Kits\10\Include\10.0.22000.0\ucrt
        C:\Windows Kits\10\Include\10.0.22000.0\shared
        C:\Windows Kits\10\Include\10.0.22000.0\um
        C:\Windows Kits\10\Include\10.0.22000.0\winrt
        C:\Windows Kits\10\Include\10.0.22000.0\cppwinrt
        C:\Dev\Sources\YetAnotherEngine\src
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c++23
    IntelliSense Mode: windows-clang-x64
    Other Flags:
        --clang
        --clang_version=160000
        --ms_compatibility
[ C:\Dev\Sources\YetAnotherEngine\src\main.cpp ]:
    Process ID: 25544
    Memory Usage: 127 MB
    Compiler Path: C:\Dev\LLVM\bin\clang.exe
    Includes:
        C:\Dev\Sources\YetAnotherEngine\lib
        C:\Dev\Sources\YetAnotherEngine\lib\imgui
        C:\Dev\Sources\YetAnotherEngine\lib\glfw\include
        C:\Dev\LLVM\lib\clang\16\include
        C:\Dev\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include
        C:\Dev\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\atlmfc\include
        C:\Windows Kits\10\Include\10.0.22000.0\ucrt
        C:\Windows Kits\10\Include\10.0.22000.0\shared
        C:\Windows Kits\10\Include\10.0.22000.0\um
        C:\Windows Kits\10\Include\10.0.22000.0\winrt
        C:\Windows Kits\10\Include\10.0.22000.0\cppwinrt
        C:\Dev\Sources\YetAnotherEngine\src
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c++23
    IntelliSense Mode: windows-clang-x64
    Other Flags:
        --clang
        --clang_version=160000
        --ms_compatibility
Total Memory Usage: 319 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 5805

Other Extensions

No response

Additional context

image

Colengms commented 1 year ago

Hi @BluTree . The C/C++ Extension leverages the EDG compiler front-end and is equivalent to the EDG eccp column in this table: https://en.cppreference.com/w/cpp/compiler_support/23

We'll keep this issue open for tracking, but expect this feature to start working as expected once EDG has added support for it.

starball5 commented 4 months ago

Related on Stack Overflow: VS Code cpptools 1.20 does not support C++23 multidimensional subscript operator in IntelliSense. Why?