microsoft / microsoft/vscode-cpptools
__has_attribute(X) bad evaluation
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 6.2k
- Fork
- 1.7k
- Merge medio
- 14h 46m
- PR unite (30g)
- 61
Descrizione
Environment
- OS and Version: Ubuntu 22.10
- VS Code Version: e2816fe7 (snap store)
- C/C++ Extension Version: v1.13.9
- If using SSH remote, specify OS of remote machine: none
- C standard : gnu17
Bug Summary and Steps to Reproduce
Bug Summary:
I'm working on a C project. I wrote something like this (actually not exactly like this, but I tried to rewrite it with the same conditionals) :
#if defined(__has_attribute)
#define ATTRIBUTE_CHECKING 1
#endif
#if ATTRIBUTE_CHECKING && __has_attribute(copy)
#define ATTRIBUTE_COPY 1
#else
#error "Attribute copy not available"
#endif
The problem is that I configured Intellisense with linux-gcc-x64 with gcc (12.2.0), and the condition
ATTRIBUTE_CHECKING && __has_attribute(copy)
is considered false when it's supposed to be true. I made this simple test, in the same workspace, with the same settings, ... :
#include <stdio.h>
int main()
{
printf("%d\n", __has_attribute(copy));
return 0;
}
and it printed "1".
I also tried with attribute access, and the same issue appears.
Steps to reproduce:
- Just copy the macros and the main function and you'll see
Expected behavior:
I think it's supposed to be true considering my config.
NOTE
For the "logs from the language server logging", I deleted the macros detailed above and ctrl+z' them, then copied the result into the proper section, since it wasn't enabled before.
Configuration and Logs
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/axel/Documents/programmation/c/FManC/test/third_party/"
],
"defines": [],
"compilerPath": "/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++23",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [],
"mergeConfigurations": false
}
],
"version": 4
}
C/C++: Log Diagnostics
-------- Diagnostics - 2/7/2023, 9:15:42 PM
Version: 1.13.9
Current Configuration:
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/axel/Documents/programmation/c/FManC/test/third_party/"
],
"defines": [],
"compilerPath": "/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++23",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [],
"mergeConfigurations": false,
"compilerPathIsExplicit": true,
"cStandardIsExplicit": true,
"cppStandardIsExplicit": true,
"intelliSenseModeIsExplicit": true
}
Translation Unit Mappings:
[ /home/axel/Documents/programmation/c/FManC/test.c ]:
/home/axel/Documents/programmation/c/FManC/test.c
[ /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h ]:
/home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
/home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_platform.h *
Translation Unit Configurations:
[ /home/axel/Documents/programmation/c/FManC/test.c ]:
Process ID: 41594
Memory Usage: 107 MB
Compiler Path: /bin/gcc
Includes:
/home/axel/Documents/programmation/c/FManC/test/third_party
/usr/include/c++/12
/usr/include/x86_64-linux-gnu/c++/12
/usr/include/c++/12/backward
/usr/lib/gcc/x86_64-linux-gnu/12/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
Standard Version: c++23
IntelliSense Mode: linux-gcc-x64
Other Flags:
--g++
--gnu_version=120200
[ /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h ]:
Process ID: 42694
Memory Usage: 107 MB
Compiler Path: /bin/gcc
Includes:
/home/axel/Documents/programmation/c/FManC/test/third_party
/usr/lib/gcc/x86_64-linux-gnu/12/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
Standard Version: c17
IntelliSense Mode: linux-gcc-x64
Other Flags:
--gcc
--gnu_version=120200
--header_only_fallback
Total Memory Usage: 215 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 22328
Logs from the language server logging
loggingLevel: Debug
loggingLevel has changed to: Debug
cpptools/didChangeCppProperties
$/setTrace
cpptools/didChangeSettings
Enhanced Colorization is enabled.
Autocomplete is enabled.
Error squiggles are enabled.
Hover is enabled.
IntelliSense Engine = default.
$/setTrace
cpptools/didChangeSettings
Enhanced Colorization is enabled.
Autocomplete is enabled.
Error squiggles are enabled.
Hover is enabled.
IntelliSense Engine = default.
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_platform.h (id: 13161)
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/activeDocumentChange: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_platform.h
cpptools/getInlayHints: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_platform.h (id: 13162)
cpptools/getFoldingRanges: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_platform.h (id: 13163)
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_platform.h (id: 13164)
idle loop: reparsing the active document
Checking for syntax errors: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_platform.h
Queueing IntelliSense update for files in translation unit of: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
cpptools/finishUpdateSquiggles
Error squiggle count: 1
Error squiggle count: 0
Update IntelliSense time (sec): 0.254
cpptools/getSemanticTokens: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_platform.h (id: 13165)
cpptools/getSemanticTokens: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13166)
cpptools/getFoldingRanges: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_platform.h (id: 13167)
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13168)
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/activeDocumentChange: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
cpptools/getInlayHints: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13169)
cpptools/getFoldingRanges: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13170)
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13171)
idle loop: reparsing the active document
Checking for syntax errors: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
Queueing IntelliSense update for files in translation unit of: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
cpptools/finishUpdateSquiggles
Error squiggle count: 1
Update IntelliSense time (sec): 0.252
cpptools/getSemanticTokens: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13172)
cpptools/getFoldingRanges: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13173)
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13174)
cpptools/textEditorSelectionChange
textDocument/documentHighlight: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13175)
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13176)
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13177)
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13178)
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13179)
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13180)
cpptools/textEditorSelectionChange
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13181)
textDocument/didChange: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
cpptools/textEditorSelectionChange
cpptools/getFoldingRanges: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13182)
cpptools/getSemanticTokens: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13183)
cpptools/getDocumentSymbols: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13184)
cpptools/getDocumentSymbols
cpptools/getInlayHints: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13185)
Checking for syntax errors: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
tag parsing file: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
Queueing IntelliSense update for files in translation unit of: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
sending 1 changes to server
cpptools/finishUpdateSquiggles
Error squiggle count: 3
Update IntelliSense time (sec): 2.252
cpptools/getFoldingRanges: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13186)
textDocument/didChange: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
cpptools/textEditorSelectionChange
cpptools/getFoldingRanges: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13187)
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13188)
cpptools/getSemanticTokens: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13189)
cpptools/getDocumentSymbols: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13190)
cpptools/getDocumentSymbols
cpptools/getInlayHints: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13191)
Checking for syntax errors: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
tag parsing file: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
Queueing IntelliSense update for files in translation unit of: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h
sending 1 changes to server
cpptools/finishUpdateSquiggles
Error squiggle count: 1
Update IntelliSense time (sec): 2.252
cpptools/getFoldingRanges: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13192)
cpptools/getCodeActions: /home/axel/Documents/programmation/c/FManC/src/general/preprocessor/FMC_attributes.h (id: 13193)
Other Extensions
No response
Additional context
Here are the kind of macros I originally had


As you can see it seems like there's no attribute access.
The simple test

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
Riprodurre la condizione in test.c utilizzando la configurazione c_cpp_properties.json e confrontare IntelliSense con il risultato di GCC. Esaminare l’elaborazione di FMC_attributes.h e FMC_platform.h, quindi verificare che __has_attribute(copy) venga valutato in modo coerente nella condizione segnalata e che la diagnostica della condizione falsa non venga più visualizzata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, vscode
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100