Type: LanguageService
Describe the bug
The symbol search function in the command pallette (Ctrl-Shift-O) lists symbols which are return values of functions, resulting in duplicate symbols being listed (legitimate definitions and those in function prototypes/declarations).
To Reproduce
.h file. struct tag definition, with optional fields.struct (or perhaps a pointer to said struct)@ symbol in the command pallettestructExpected behavior
Only one symbol is listed in the search, pointing to the definition of the struct tag.
Screenshots

Screenshot showing multiple flag symbols, only the first of which belongs to the definition of the struct flag.
Additional context
c_cpp_properties.json
This issue is present anywhere that symbols are listed. Including but not limited to @ cmd palette search, # cmd palette search, OUTLINE Explorer View, Alt+N symbol view, etc...
Any progress on confirming my issue?
Are you also defining an alias for the struct? I don't repro with the following code:
struct A {};
A* get_A();
void main()
{
A* asdf = get_A();
}
but I do with the following (which is currently the expected behavior):
typedef struct A {} A;
A* get_A();
void main()
{
A* asdf = get_A();
}
Can you share a code snippet that manifests your problem?
The following snippet, when saved as a .h file, gives the following results in OUTLINE view, Ctrl+O symbol search, Alt+N search and Ctrl + T symbol search:
struct flag {
int a;
};
typedef struct flag Flag;
const struct flag *fget(int a, int b, int c);

The first flag symbol belongs to the struct tag definition, which is OK, but the 2nd and 3rd belong to the typedef and the function prototype, respectively. The capitalized Flag is expected, as it's a separate type definition.
It seems that struct tag definitions get picked up as duplicated symbols when included in function prototypes. (e.g. from your example, A* get_A(); doesn't produce a duplicate as A is typdef'd, but struct A* get_A(); does), and in typedef definitions.
I believe only one flag symbol should be listed, no?
Oh, I see. Yeah, it's probably because of the struct keyword before each reference to flag. We'll investigate.
VS 2017 shows similar results for global symbols, although they don't seem to have an Outline view. Yeah, looks like our symbol parser or our usage isn't correctly handling the C-style "struct name" usage.
We have improved the scenario via adding (declaration) to the instances that are declaration, but there is still a bug with the use of "struct s" as a type (not a declaration). It's being tracked by https://developercommunity.visualstudio.com/content/problem/456439/cc-intellisense-incorrectly-treats-struct-mystruct.html so you can upvote that.