vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Find all references not working for anonymous structs in C

Open RichardFurness opened this issue 6 years ago • 3 comments

Testing out "find all references" support in the 0.25-insiders version, I've found that if I have a typedef'd anonymous struct i.e.:

typedef struct { int foo; } my_type;

then "find all references" from the typedef or any element of the struct fails to find any references (they all appear as "not a reference" in the output). Conversely, if I do "find all references" from an actual reference, then it finds them all APART from the definition.

But if I add a name for the struct it all works fine e.g.:

typedef my_struct struct { int foo; } my_type;

RichardFurness avatar Aug 14 '19 10:08 RichardFurness

It repros with .c files not .cpp. VS has a similar bug in that uses of "foo" in .c files are marked incorrectly as "Not a Reference", but it finds the defintion -- I think it's the same root bug just with a different symptom due to differences in how the root bug is handled. I've filed bug https://developercommunity.visualstudio.com/content/problem/696662/cc-find-all-references-gives-not-a-reference-for-m.html .

sean-mcmanus avatar Aug 15 '19 22:08 sean-mcmanus

Hit this today (on the way back from CLion).

Refactoring is impacted as well (i.e. rename doesn't rename the usages of anonymous structs/unions.)

morew4rd avatar Mar 18 '24 17:03 morew4rd

I wasn't able to reproduce with a test case so I'm not filing a new bug, but this is probably related:

The reference to emulate on this line: https://github.com/dsalt/devilspie2/blob/760df8ce0db8f51c75acbb27ab0e420174cb8352/src/devilspie2.c#L321 also triggers the "NOT A REFERENCE" behavior when doing "Find All References" on another reference to emulate.

My example and this whole bug may also be related to #4173

sparr avatar Oct 04 '24 12:10 sparr

The Visual Studio ticket linked to this issue was closed without a fix. Unfortunately, that means a fix will not be coming to VS Code either.

bobbrow avatar Nov 27 '24 21:11 bobbrow