microsoft / microsoft/vscode-cpptools
Errors calling functions with enum type parameters that are defined in structs
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 6.2k
- Fork
- 1.7k
- Merge medio
- 14h 46m
- PR unite (30g)
- 61
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con l’esempio di codice foo.c riprodotto e i log del language server collegati, quindi traccia il modo in cui il language service risolve i tipi enum dichiarati all’interno di structs e diagnostica gli argomenti delle funzioni. Il lavoro è completato quando l’esempio non produce falsi errori né per le variabili enum né per l’enumeratore A, e il comportamento di gcc e clang rimane coerente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, typescript
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100