Distilled from: http://www.linuxquestions.org/questions/linux-from-scratch-13/replace-gcc-with-clang-4175491981/#post5108443 extern void foo(void); #define TEST int bar(void) { #if TEST foo(); #endif return 0; } Currently: test.c:6:9: error: #if with no expression #if TEST ^ Expected something like: test.c:6:9: error: #if with no expression #if TEST ^ test.c:2:14: note: in expansion of macro ‘TEST’ I think this could be possible by giving the error at the location of TEST (which should be the previously encoded source_location) rather that at the current one. #define TEST ^
Maybe someone might want to put something else after TEST. I think both are correct to warn. clang error location might be more useful in some cases but wrong in others. Likewise the way GCC is correct for some cases but wrong for others. The biggest question is which happens more often in real life. I don't have any thoughts on that one.
(In reply to Andrew Pinski from comment #1) > Maybe someone might want to put something else after TEST. I think both are > correct to warn. clang error location might be more useful in some cases > but wrong in others. Likewise the way GCC is correct for some cases but > wrong for others. The biggest question is which happens more often in real > life. I don't have any thoughts on that one. Note that Clang gives the same location as GCC. My suggestion is to improve over clang to show the macro value as empty. If one adds something after TEST, then the error (and locations) would be totally different, which is ok.