microsoft / microsoft/vscode-cpptools

Incorrect errors when __attribute__ is used on enum values in gcc mode

Aperta
#4,885 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug Language Service more votes needed Visual Studio
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

Type: LanguageService

Describe the bug

  • OS and Version: Fedora 31
  • VS Code Version: 1.41
  • C/C++ Extension Version: 0.26.3
  • Other extensions you installed (and if the issue persists after disabling them): TBD (how can I disable every extension except for this one? I have 50 extensions installed.)
  • A clear and concise description of what the bug is.

There is an identifier exported from GLib, G_PARAM_STATIC_STRINGS (a macro), that is marked as undefined (has red squiggles) even though I can Ctrl+click it to show the definition. Seeing the definition shows no errors. The file that the macro is defined also reports an unusual error though, where an ending } is expected. Not sure if this is throwing off the language server, but something is off.

To Reproduce

repository in question: https://git.sr.ht/~tristan957/harvest-almanac (also mirrored on my GitHub if more convenient)
example of usage: https://git.sr.ht/~tristan957/harvest-almanac/tree/d5ebeb13fb59b3c99e3c43c290b7b7e7aed51020/harvest-glib/harvest-project.c#L334

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/harvest-glib",
                "/usr/include/gtk-3.0",
                "/usr/include/glib-2.0",
                "/usr/lib64/glib-2.0/include",
                "/usr/include/pango-1.0",
                "/usr/include/cairo",
                "/usr/include/gdk-pixbuf-2.0",
                "/usr/include/atk-1.0",
                "/usr/include/libhandy-0.0",
                "/usr/include/json-glib-1.0",
                "/usr/include/libsoup-2.4",
                "/usr/include/libsecret-1",
                "/usr/include/harfbuzz",
                "/home/tristan957/.local/include",
                "${workspaceFolder}/build/harvest-glib"
            ],
            "defines": [
                "__HARVEST_HEADER_INTERNAL__"
            ],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
        }
    ],
    "version": 4
}
  1. Open the repo in VSCode
  2. Go to harvest-glib/harvest-project.c line 334, see error on line 335 (any .c file should show the same error fyi)
  3. Notice squiggles
  4. Ctrl+click (now viewing gparam.h) (https://gitlab.gnome.org/GNOME/glib/blob/master/gobject/gparam.h#L175)
  5. Notice error on line 159 of file (https://gitlab.gnome.org/GNOME/glib/blob/master/gobject/gparam.h#L159)
  6. Follow the definition of GLIB_DEPRECATED_ENUMERATOR_IN_2_26 to gversionmacros.h and then to gmacros.h
  7. See that GLIB_DEPRECATED_ENUMERATOR_IN_2_26 eventually gets defined as __attribute__((__deprecated__))

Expected behavior
Not misreport a defined identifier.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da harvest-glib/harvest-project.c intorno alla riga 334 usando il c_cpp_properties.json fornito, quindi esamina gparam.h intorno alla riga 159 e segui GLIB_DEPRECATED_ENUMERATOR_IN_2_26 attraverso gversionmacros.h e gmacros.h. Riproduci le diagnosi e verifica che l’identificatore definito G_PARAM_STATIC_STRINGS e la posizione della relativa graffa di chiusura non vengano più segnalati erroneamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c, vscode
Ambito
devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.