ccls
ccls copied to clipboard
ccls does not recognize C attributes
Observed behavior
ccls gives an error on C attributes (feature was standardized in C23 and is supported by clang 9 and gcc 10).
Minimal example:
[[nodiscard]] void* identity(void* item) {
return item;
}
Expected behavior
No error (feature standardized in C23).
Steps to reproduce
Minimal example:
[[nodiscard]] void* identity(void* item) {
return item;
}
System information
- ccls version (
git describe --tags --long): 0.20240202 - clang version: 14.0.6
- OS: Linux nixos 6.6.32
- Editor: Neovim
- Language client (and version):
Did you use -std=c2x or -std=c23 as compilation flag?
As your ccls seems to be build against clang 14.0.6 (which has been released in 2022 while C23 is only official since February), I suppose you are compiling with the later when you should use the former to make ccls use the correct C version.
As my box runs Debian testing (which rely on llvm 19.x), I did some tests using a c27 project with ccls and clangd:
- ccls does not complain at all (surely because it fell back to c23);
- clangd-16 complains about the wrong compilation flag and the C attribute (surely because it fell back to c17);
- clangd-19 complains about the wrong compilation flag but not about the C attribute (surely because it fell back to c23).