Sarcasm / flycheck-irony

C, C++ and Objective-C support for Flycheck, using Irony Mode
56 stars 10 forks source link

"Unterminated conditional directive" when using nested ifdefs #20

Closed sonictk closed 6 years ago

sonictk commented 6 years ago

Currently, flycheck throws me the error on the first line of the following code sample:

#ifdef TEST

static const char *test = "tghafg";

#ifdef MACRO

static const int test2 = 2;

#endif // MACRO

#endif // TEST

The full error messages are:

     1   2 error           unterminated conditional directive (irony)
    11   2 error           #endif without #if (irony)

If I remove the statement of initializing test2, the error goes away (Which doesn't mean much except that it's probably not related to some out-of-date cache).

This seems to happen on Linux (Tested on both CentOS7/Ubuntu 17.04). I tested against the latest irony-mode a571167eca2533343f523f0c9ee3886de2d7b917 building against Clang 6.0.0.

This does not seem to occur on Windows.

The code compiles fine, and as far as I know this is valid C++, (If I'm wrong, please let me know!) so I'm wondering if there is something I can do about this?

Sarcasm commented 6 years ago

Ah, thanks for the minimal reproducible example. I can confirm the issue, which is already filled in the irony-mode bug tracker:

This is really weird. I do not have much time to work around this issue right now. But it would be interesting to compare with the code here:

And if it does not reproduce, see what is different in irony-mode.

There is also https://github.com/llvm-mirror/clang/blob/master/tools/c-index-test/c-index-test.c which may be worth comparing too.

Sarcasm commented 6 years ago

Should be fixed in LLVM master: