MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.72k stars 254 forks source link

Header file warnings appear in source file #941

Open tesselslate opened 1 year ago

tesselslate commented 1 year ago

Edit: Initially, I only observed this with "declaration without prototype" cases. It seems to appear with other warnings, such as "internal linkage but not defined."

Observed behavior

When a function is declared in a header file and an identically named function prototype is in a source file, ccls produces a warning in the source file instead of the header file. The warning appears at the same spot as it would if it were in the header file.

This only occurs when the header file contains a definition and not a prototype.

image

Expected behavior

The warning should either appear in the header file where the function is initially declared (as it does when running clang), or at the prototype in the source file.

Steps to reproduce

test.c:

#include "test.h"

void a(int x) {}

test.h:

void a();

System information