microsoft / microsoft/vscode-cpptools

IntelliSense fails to handle aliased struct

Open
#12,724 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Windows 10
  • VS Code Version: 1.84.2
  • C/C++ Extension Version: 1.21.6
  • If using SSH remote, specify OS of remote machine:
Bug Summary and Steps to Reproduce

Bug Summary:
When aliasing is used for struct that uses same name as namespace then IntelliSense shows error.

Steps to reproduce:

  1. Paste in code:
namespace AAA
{
    struct AAA
    {
        int integer;
    };

    int AAAtest(int a)
    {
        return a + 10;
    }
}

namespace BBB
{
using AAA = AAA::AAA; // shows error

void test(AAA *aa)
{
    aa->integer++;
    int result = ::AAA::AAAtest(10);
}
}
  1. Error overloaded function "AAA::AAA::AAA" is not a type nameC/C++(757) will be shown on mouse hover over using AAA = AAA::AAA; line.

Expected behavior:
No error should be shown here.
Code compiles using clang version 14.0.6 Android (8490178, based on r450784d) (other compilers not tested).

Configuration and Logs
{
    "configurations": [
        {
            "name": "android",
            "includePath": [
                "${workspaceFolder}/src/**"
            ],
            "defines": [
                "_DEBUG",
                "DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "${workspaceFolder}/../android_sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe",
            "cStandard": "c11",
            "cppStandard": "c++11",
            "intelliSenseMode": "linux-clang-arm64",
            "browse": {
                "limitSymbolsToIncludedHeaders": true
            },
            "compilerArgs": [
                "--target=aarch64-unknown-linux-android26",
                "-Werror",
                "-pedantic-errors",
                "--std=c++11",
                "-fPIC",
                "-ferror-limit=0",
                "-fstack-protector-strong",
                "-Wno-writable-strings",
                "-Wno-gnu-anonymous-struct",
                "-Wno-nested-anon-types",
                "-Wl,--no-undefined-version",
                "-Wl,-undefined,error",
                "-Wl,--error-unresolved-symbols",
                "-Wl,--no-undefined",
                "-Wl,-error-limit=0",
                "-Wl,--build-id=sha1",
                "-mno-relax"
            ]
        }
    ],
    "version": 4
}
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 by reproducing the provided C++ snippet in VS Code with the C/C++ extension and confirm the diagnostic on the aliased struct. Trace the IntelliSense diagnostic for using AAA = AAA::AAA;; done means the valid alias produces no error while aa->integer++ and the qualified function call remain recognized.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.