-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Bug type: Language Service
Describe the bug
-
OS and Version: Ubuntu 21.10
-
VS Code Version: 1.63.2
-
C/C++ Extension Version: 1.7.1 & 1.8.3
-
Other extensions you installed (and if the issue persists after disabling them): Still persists after disabling all other extensions
-
A clear and concise description of what the bug is:
When a function declaration OR a separate function declaration + its definition is marked as
static
and it has any parameter whose type is a struct that is nested inside another struct or union (regardless if it is a value or pointer parameter), then the function is marked with the errordeclaration is incompatible with "void func_name(struct struct_name param_name)" (declared at line N)
.
This is a false positive; the program compiles without any errors (tested with both GCC and Clang).When the function is defined right away, without any previous prototype declaration, the error is not issued.
Also, when the nested struct parameter is a value, not a pointer, then passing in a valid value will issue the error:
argument of type "struct struct_name" is incompatible with parameter of type "struct struct_name"
.
This happens regardless of the function being markedstatic
or not, and also regardless of the function prototype being declared before defining it.
Steps to reproduce
- Create a C file
- Declare a struct that is nested inside another struct or union
- Declare (not define, though a definition can be written later and the bug still persists) a function that is marked
static
and has the nested struct as a parameter (value or pointer) - See error
Expected behavior
False positive; expected no errors.
Code sample and logs
-
Code sample
struct foo { long l; struct bar { int i; } bar; }; static void func(struct bar b); int main() { struct bar b = { .i = 0 }; func(b); } static void func(struct bar b) {}
-
No
c_cpp_properties.json
- everything default values -
Logs from running
C/C++: Log Diagnostics
from the VS Code command palette-------- Diagnostics - 2/1/2022, 11:06:17 AM Version: 1.8.3 Current Configuration: { "name": "Linux", "includePath": [ "${workspaceFolder}/**" ], "defines": [], "compilerPath": "/usr/local/bin/gcc", "cStandard": "gnu17", "cppStandard": "gnu++17", "intelliSenseMode": "linux-gcc-x64", "compilerArgs": [], "intelliSenseModeIsExplicit": false, "cStandardIsExplicit": false, "cppStandardIsExplicit": false, "mergeConfigurations": false, "compilerPathIsExplicit": false, "browse": { "path": [ "${workspaceFolder}/**" ], "limitSymbolsToIncludedHeaders": true } } Translation Unit Mappings: [ /tmp/tmp.ZXVQY0SYhg/main.c ]: /tmp/tmp.ZXVQY0SYhg/main.c Translation Unit Configurations: [ /tmp/tmp.ZXVQY0SYhg/main.c ]: Process ID: 32470 Memory Usage: 11 MB Compiler Path: /usr/local/bin/gcc Includes: /usr/local/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include /usr/local/include /usr/local/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include-fixed /usr/include/x86_64-linux-gnu /usr/include Standard Version: c17 IntelliSense Mode: linux-gcc-x64 Other Flags: --gcc --gnu_version=120000 Total Memory Usage: 11 MB ------- Workspace parsing diagnostics ------- Number of files discovered (not excluded): 16661
-
Logs from the language server logging
loggingLevel: Debug loggingLevel has changed to: Debug cpptools/didChangeCppProperties $/setTraceNotification cpptools/getCodeActions: /tmp/tmp.ZXVQY0SYhg/main.c (id: 312) cpptools/textEditorSelectionChange cpptools/getDocumentSymbols: /tmp/tmp.ZXVQY0SYhg/main.c (id: 313) cpptools/getDocumentSymbols cpptools/textEditorSelectionChange cpptools/activeDocumentChange: /tmp/tmp.ZXVQY0SYhg/main.c cpptools/getCodeActions: /tmp/tmp.ZXVQY0SYhg/main.c (id: 314) idle loop: reparsing the active document Checking for syntax errors: /tmp/tmp.ZXVQY0SYhg/main.c Queueing IntelliSense update for files in translation unit of: /tmp/tmp.ZXVQY0SYhg/main.c cpptools/textEditorSelectionChange cpptools/finishUpdateSquiggles Error squiggle count: 2 Update IntelliSense time (sec): 0.256 cpptools/getSemanticTokens: /tmp/tmp.ZXVQY0SYhg/main.c (id: 315) willSaveWaitUntil: 0ms textDocument/didSave: /tmp/tmp.ZXVQY0SYhg/main.c tag parsing file: /tmp/tmp.ZXVQY0SYhg/main.c cpptools/fileChanged: /tmp/tmp.ZXVQY0SYhg/main.c idle loop: reparsing the active document Checking for syntax errors: /tmp/tmp.ZXVQY0SYhg/main.c Queueing IntelliSense update for files in translation unit of: /tmp/tmp.ZXVQY0SYhg/main.c cpptools/finishUpdateSquiggles Error squiggle count: 2 Update IntelliSense time (sec): 0.252 cpptools/getSemanticTokens: /tmp/tmp.ZXVQY0SYhg/main.c (id: 317)
Screenshots