microsoft / microsoft/vscode-cpptools
Errors calling functions with enum type parameters that are defined in structs
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 6.2k
- Forks
- 1.7k
- Ø Merge
- 14 Std. 46 Min.
- Gemergte PRs (30 T.)
- 61
Beschreibung
Bug type: Language Service
Describe the bug
- OS and Version: Ubuntu 2021.10
- VS Code Version: 1.65.2
- C/C++ Extension Version: v1.9.2
- Other extensions you installed (and if the issue persists after disabling them): None
- If using SSH remote, specify OS of remote machine: N/A
If an enum type is defined in a struct and that enum type is used as the type of a function parameter all attempts to pass a value on that parameter will cause an error.
Steps to reproduce
Copy-paste the below code.
Expected behavior
This should not error. Neither gcc nor clang consider this an error or even a warning (with -Weverything).
Code sample and logs
struct Foo {
enum FooType {
A, B, C
} type;
};
void use_FooType(enum FooType type) { (void)type; }
void call_with_enum(void)
{
enum FooType type = A;
use_FooType(type); // argument of type "enum FooType" is incompatible with parameter of type "enum FooType"
}
void call_with_int(void)
{
use_FooType(A); // argument of type "int" is incompatible with parameter of type "enum FooType"
}
Configurations in `c_cpp_properties.json`
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/include"
],
"defines": [],
"compilerPath": "/usr/lib/ccache/clang",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
Logs from running `C/C++: Log Diagnostics` from the VS Code command palette
-------- Diagnostics - 4/3/2022, 9:50:00 AM
Version: 1.9.7
Current Configuration:
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/include"
],
"defines": [],
"compilerPath": "/usr/lib/ccache/clang",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "linux-clang-x64",
"compilerPathIsExplicit": true,
"cStandardIsExplicit": true,
"cppStandardIsExplicit": true,
"intelliSenseModeIsExplicit": true,
"compilerArgs": [],
"mergeConfigurations": false,
"browse": {
"path": [
"${workspaceFolder}/include",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
}
}
Translation Unit Mappings:
[ /home/kaleb/dev/scratch/foo.c ]:
/home/kaleb/dev/scratch/foo.c
Translation Unit Configurations:
[ /home/kaleb/dev/scratch/foo.c ]:
Process ID: 4394
Memory Usage: 17 MB
Compiler Path: /usr/lib/ccache/clang
Includes:
/home/kaleb/dev/scratch/include
/usr/lib/llvm-13/lib/clang/13.0.0/include
/home/kaleb/include
/usr/include/x86_64-linux-gnu
/usr/include
Standard Version: c17
IntelliSense Mode: linux-clang-x64
Other Flags:
--clang
--clang_version=130000
Total Memory Usage: 17 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 4941
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem reproduzierten foo.c-Codebeispiel und den verknüpften Language-Server-Logs und verfolge dann, wie der Language Service enum-Typen auflöst, die innerhalb von structs deklariert sind, und Funktionsargumente diagnostiziert. Als abgeschlossen gilt die Aufgabe, wenn das Beispiel weder für enum-Variablen noch für den Enumerator A falsche Fehler erzeugt und das Verhalten von gcc und clang konsistent bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, typescript
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100