I stumbled upon a C file (well, I wrote it :) that trips the parser for the symbol table. For a while, number literals in C++ and C can be partitioned visually by using single quotes, e.g., `0b0000'0000` - so-called digit separators. This has finally been standardized in C23 (and previously in C++14).
I have found that in case of initializing a subelement (e.g., a struct within an array of structs, i.e., within a second pair of curly braces), the quotes are not handled correctly. If the quotes appear in pairs it's fine which makes me think it tries to match them to find character literals.
See below for a demo. Notice how the function `test_func` vanishes from the symbol table depending on the amount of `'`s.
![Recording](https://github.com/user-attachments/assets/258830fa-4b49-456d-98ab-b0ba94c2e...)
I have only tested this with Geany 1.38. Here is the test case for easy verification:
struct something arr[] = { { 0b0000'0000 }, };
void test_func(void) { }
I'm afraid this is how the ctags parsers work - they assume the code is correct and there isn't a robust parsing error recovery. You'll run into the same when adding `{` before closing it.
Well, yes, I am not particularly concerned with the handling of erroneous code by the parser but the code is completely fine and thus should be parsed correctly. Do you imply that this isn't a bug within geany (or its included ctags copy) but an error in upstream universal ctags?
Ah, right, this is a valid code, I didn't read your description carefully enough, sorry.
This is definitely universal ctags problem then and should be reported there. Just to be sure, you should try with the ctags binary first if it stops generating tags when `'` is present. It's also possible that it has been fixed there in the meantime and Geany just has an old version without the fix.
I suspect that what happens is that as `'` is the opening quote for character literals, ctags thinks it's within a character and doesn't emit tags until the "final" `'` which never comes.
@stefanct Actually what Geany version are you using? This seems to work alright in current Geany master.
Closed #4078 as completed.
Closing as I think this works with the current development version of Geany. Feel free to reopen if you feel the problem still exists.
github-comments@lists.geany.org