microsoft / microsoft/vscode-cpptools

C23 features aren't supported

Open
#10,696 46 comments 190 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request Language Service parser
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Ubuntu 22.04
  • VS Code Version: 1.76.2
  • C/C++ Extension Version: 1.15.0
  • If using SSH remote, specify OS of remote machine:
Bug Summary and Steps to Reproduce

Bug Summary:

There was an issue (#10615) that allows you to select c23/gnu23 as your compiler version, but the actual new language features are not implemented yet. Obviously this stuff is bleeding edge, but I struggled trying to get it to work and I wanted to submit an issue.

I would be happy to work on adding these features to the C/C++ language server, but I would need to be pointed in the right direction.

Steps to reproduce:

  1. Set your C standard version to c23 or gnu23
  2. Open the following code with IntelliSense active
enum TestEnum : short
{
    TEST_ENUM_VALUE,
};

void doSomething() {
    int * test1 = nullptr;
    bool test2 = true; // without #include <stdbool.h>
    enum TestEnum test3 = TEST_ENUM_VALUE;
}
  1. Verify that these all generate "Problems"
    image

  2. Compile with -std=gnu2x or equivalent, on a very new compiler (I used clang 17) and verify that there are no errors

Expected behavior:
Generate the same errors that clang 17 would, or equivalent

Configuration and Logs
{
    "configurations": [
        {
            "name": "Linux",
            "compilerPath": "/usr/bin/clang-17",
            "cStandard": "c23",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
        }
    ],
    "version": 4
}

-------- Diagnostics - 3/17/2023, 1:56:58 AM
Version: 1.15.0
Current Configuration:
{
    "name": "Linux",
    "compilerPath": "/usr/bin/clang-17",
    "cStandard": "c23",
    "compileCommands": "WORKSPACE/build/compile_commands.json",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": false,
    "intelliSenseModeIsExplicit": false,
    "rawCompilerPath": "/usr/bin/clang-17",
    "mergeConfigurations": false,
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ WORKSPACE/src/test.c ]:
    WORKSPACE/src/test.c
Translation Unit Configurations:
[ WORKSPACE/src/test.c ]:
    Process ID: 3852781
    Memory Usage: 544 MB
    Compiler Path: /usr/bin/clang-17
    Includes:
        /usr/lib/llvm-17/lib/clang/17/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c23
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=170000
    compile_commands.json entry:
        directory: WORKSPACE/build
        file: WORKSPACE/src/test.c
        command: /usr/bin/clang   -g -std=gnu2x -o WORKSPACE/build/src/test.c.o -c WORKSPACE/src/test.c
        output: CMakeFiles/slwjson.dir/src/test.c.o
Total Memory Usage: 544 MB
Browse Paths from compile_commands.json, from workspace folder: WORKSPACE
    WORKSPACE/src
Other Extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the C/C++ language server's IntelliSense handling for the c23 and gnu23 standards, using the example in WORKSPACE/src/test.c and the supplied clang 17 configuration. Reproduce the reported Problems, then verify that the C23 enum syntax, nullptr, and bool usage are accepted with diagnostics matching clang 17.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers, devtools
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.